SlideShare a Scribd company logo
1 of 1
Download to read offline
...tsTryLambdaExpressionsTryLambdaExpressionsProgram.cs 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TryLambdaExpressions
{
class Program
{
// Function that calculates the difference between two integers
// Old Method
static int mydifferenceold(int x, int y)
{
return x - y;
}
// Lambda Expression that calculates the difference between two
integers
// New Method
static int mydifferencenew(int x, int y) => x - y;
static void Main()
{
// Define Data Types
int i = 18;
int j = 7;
int kold = mydifferenceold(i, j);
int knew = mydifferencenew(i, j);
// Print Results
Console.WriteLine($"i is {i}");
Console.WriteLine($"j is {j}");
Console.WriteLine($"kold (Difference between i and j - old
method) is {kold}");
Console.WriteLine($"knew (Difference between i and j - new
method) is {knew}");
}
}
}

More Related Content

What's hot

CS50 Lecture4
CS50 Lecture4CS50 Lecture4
CS50 Lecture4昀 李
 
STRUCTURES IN C PROGRAMMING
STRUCTURES IN C PROGRAMMING STRUCTURES IN C PROGRAMMING
STRUCTURES IN C PROGRAMMING Gurwinderkaur45
 
Recursion concepts by Divya
Recursion concepts by DivyaRecursion concepts by Divya
Recursion concepts by DivyaDivya Kumari
 
Presentatioon on type conversion and escape characters
Presentatioon on type conversion and escape charactersPresentatioon on type conversion and escape characters
Presentatioon on type conversion and escape charactersfaala
 
Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04hassaanciit
 
Stack concepts by Divya
Stack concepts by DivyaStack concepts by Divya
Stack concepts by DivyaDivya Kumari
 
Operator overloading (binary)
Operator overloading (binary)Operator overloading (binary)
Operator overloading (binary)Ramish Suleman
 
20120810 tsql tips
20120810 tsql tips20120810 tsql tips
20120810 tsql tipsLearningTech
 
print even or odd number in c
print even or odd number in cprint even or odd number in c
print even or odd number in cmohdshanu
 
Machine Learning Game Changer for IT - Maartens Lourens
Machine Learning Game Changer for IT - Maartens LourensMachine Learning Game Changer for IT - Maartens Lourens
Machine Learning Game Changer for IT - Maartens LourensOpenCredo
 
Dynamic Swift
Dynamic SwiftDynamic Swift
Dynamic SwiftSaul Mora
 
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAMSIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAMSaraswathiRamalingam
 

What's hot (20)

Functional Reactive Programming
Functional Reactive ProgrammingFunctional Reactive Programming
Functional Reactive Programming
 
CS50 Lecture4
CS50 Lecture4CS50 Lecture4
CS50 Lecture4
 
C++ quik notes
C++ quik notesC++ quik notes
C++ quik notes
 
STRUCTURES IN C PROGRAMMING
STRUCTURES IN C PROGRAMMING STRUCTURES IN C PROGRAMMING
STRUCTURES IN C PROGRAMMING
 
WAP to add two given matrices in Java
WAP to add two given matrices in JavaWAP to add two given matrices in Java
WAP to add two given matrices in Java
 
Recursion concepts by Divya
Recursion concepts by DivyaRecursion concepts by Divya
Recursion concepts by Divya
 
Presentatioon on type conversion and escape characters
Presentatioon on type conversion and escape charactersPresentatioon on type conversion and escape characters
Presentatioon on type conversion and escape characters
 
Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04
 
Stack concepts by Divya
Stack concepts by DivyaStack concepts by Divya
Stack concepts by Divya
 
Operator overloading (binary)
Operator overloading (binary)Operator overloading (binary)
Operator overloading (binary)
 
Java(Access Modifiers)
Java(Access Modifiers)Java(Access Modifiers)
Java(Access Modifiers)
 
20120810 tsql tips
20120810 tsql tips20120810 tsql tips
20120810 tsql tips
 
print even or odd number in c
print even or odd number in cprint even or odd number in c
print even or odd number in c
 
Lab 1
Lab 1Lab 1
Lab 1
 
Machine Learning Game Changer for IT - Maartens Lourens
Machine Learning Game Changer for IT - Maartens LourensMachine Learning Game Changer for IT - Maartens Lourens
Machine Learning Game Changer for IT - Maartens Lourens
 
Dynamic Swift
Dynamic SwiftDynamic Swift
Dynamic Swift
 
Composite types
Composite typesComposite types
Composite types
 
C語言函式
C語言函式C語言函式
C語言函式
 
week-20x
week-20xweek-20x
week-20x
 
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAMSIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
SIMPLE C PROGRAMS - SARASWATHI RAMALINGAM
 

Similar to Listing for TryLambdaExpressions

AnswerNote Provided code shows several bugs, hence I implemented.pdf
AnswerNote Provided code shows several bugs, hence I implemented.pdfAnswerNote Provided code shows several bugs, hence I implemented.pdf
AnswerNote Provided code shows several bugs, hence I implemented.pdfanurag1231
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manualsameer farooq
 
Listing for CircleFunctions
Listing for CircleFunctionsListing for CircleFunctions
Listing for CircleFunctionsDerek Dhammaloka
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfmayorothenguyenhob69
 
Applying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing SpeedApplying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing SpeedPascal-Louis Perez
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisFastly
 
maxbox starter60 machine learning
maxbox starter60 machine learningmaxbox starter60 machine learning
maxbox starter60 machine learningMax Kleiner
 
Csphtp1 06
Csphtp1 06Csphtp1 06
Csphtp1 06HUST
 
in order to save data from access database and search from it in c# .pdf
in order to save data from access database and search from it in c# .pdfin order to save data from access database and search from it in c# .pdf
in order to save data from access database and search from it in c# .pdfkalerottnerheissst52
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheeltcurdt
 
Systematic Generation Data and Types in C++
Systematic Generation Data and Types in C++Systematic Generation Data and Types in C++
Systematic Generation Data and Types in C++Sumant Tambe
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3Dillon Lee
 

Similar to Listing for TryLambdaExpressions (20)

AnswerNote Provided code shows several bugs, hence I implemented.pdf
AnswerNote Provided code shows several bugs, hence I implemented.pdfAnswerNote Provided code shows several bugs, hence I implemented.pdf
AnswerNote Provided code shows several bugs, hence I implemented.pdf
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
 
Listing for CircleFunctions
Listing for CircleFunctionsListing for CircleFunctions
Listing for CircleFunctions
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 
Applying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing SpeedApplying Compiler Techniques to Iterate At Blazing Speed
Applying Compiler Techniques to Iterate At Blazing Speed
 
5 Rmi Print
5  Rmi Print5  Rmi Print
5 Rmi Print
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic Analysis
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
 
maxbox starter60 machine learning
maxbox starter60 machine learningmaxbox starter60 machine learning
maxbox starter60 machine learning
 
Csphtp1 06
Csphtp1 06Csphtp1 06
Csphtp1 06
 
39927902 c-labmanual
39927902 c-labmanual39927902 c-labmanual
39927902 c-labmanual
 
39927902 c-labmanual
39927902 c-labmanual39927902 c-labmanual
39927902 c-labmanual
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
 
00_Introduction to Java.ppt
00_Introduction to Java.ppt00_Introduction to Java.ppt
00_Introduction to Java.ppt
 
delegates
delegatesdelegates
delegates
 
in order to save data from access database and search from it in c# .pdf
in order to save data from access database and search from it in c# .pdfin order to save data from access database and search from it in c# .pdf
in order to save data from access database and search from it in c# .pdf
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheel
 
Systematic Generation Data and Types in C++
Systematic Generation Data and Types in C++Systematic Generation Data and Types in C++
Systematic Generation Data and Types in C++
 
Integration Project Inspection 3
Integration Project Inspection 3Integration Project Inspection 3
Integration Project Inspection 3
 
CODEsign 2015
CODEsign 2015CODEsign 2015
CODEsign 2015
 

Listing for TryLambdaExpressions

  • 1. ...tsTryLambdaExpressionsTryLambdaExpressionsProgram.cs 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace TryLambdaExpressions { class Program { // Function that calculates the difference between two integers // Old Method static int mydifferenceold(int x, int y) { return x - y; } // Lambda Expression that calculates the difference between two integers // New Method static int mydifferencenew(int x, int y) => x - y; static void Main() { // Define Data Types int i = 18; int j = 7; int kold = mydifferenceold(i, j); int knew = mydifferencenew(i, j); // Print Results Console.WriteLine($"i is {i}"); Console.WriteLine($"j is {j}"); Console.WriteLine($"kold (Difference between i and j - old method) is {kold}"); Console.WriteLine($"knew (Difference between i and j - new method) is {knew}"); } } }