SlideShare a Scribd company logo
1.Difference between for and foreach loop

 S.No     For loop                                   Foreach loop
 1        In case of for the variable of the loop is In case of Foreach the variable of the loop
          always be int only.                        while be same as the type of values under the
                                                     array.
 2        The For loop executes the statement or     The Foreach statement repeats a group of
          block of statements repeatedly until       embedded statements for each element in an
          specified expression evaluates to false.   array or an object collection.
 3        There is need to specify the loop          We do not need to specify the loop bounds
          bounds(Minimum, Maximum).                  minimum or maximum.
 4        example:                                   example:
          using sytem;                               using sytem;
           class class1                               class class1
            {                                         {
               static void Main()                         static void Main()
                {                                          {
                   int j=0;                                   int j=0;
                   for(int i=0; i<=10;i++)                    int[] arr=new int[]
                    {                                {0,3,5,2,55,34,643,42,23};
                       j=j+1;                                 foreach(int i in arr)
                     }                                         {
                      Console.ReadLine();                         j=j+1;
                  }                                             }
               }                                                Console.ReadLine();
                                                             }
                                                        }

2. Difference between Covariance and Contravariance

 S.No     Covariance                                 Contravariance
 1        Converting from a broader type to a        Converting from a more specific type to a
          specific type is called co-variance.If B   broader type is called contra-variance. If B is
          is derived from A and B relates to A,      derived from A and B relates to A, then we
          then we can assign A to B. Like A=B.       can assign B to A. Like B= A. This is
          This is Covariance.                        Contravariance.
 2        Co-variance is guaranteed to work         Contra-variance on the other hand is not
          without any loss of information during guaranteed to work without loss of data. As
          conversion. So, most languages also       such an explicit cast is required.
          provide facility for implicit conversion.
                                                    e.g. Converting from cat or dog to animal is
          e.g. Assuming dog and cat inherits from called contra-variance, because not all
          animal, when you convert from animal features (properties/methods) of cat or dog is
          type to dog or cat, it is called co-      present in animal.
          variance.


 3        Example:
class Fruit { }

    class Mango : Fruit { }

    class Program

    {

    delegate T Func<out T>();

    delegate void Action<in T>(T a);

    static void Main(string[] args)

        {

        // Covariance

        Func<Mango> mango = () => new Mango();

        Func<Fruit> fruit = mango;

        // Contravariance

        Action<Fruit> fr = (frt) =>

        { Console.WriteLine(frt); };

        Action<Mango> man = fr;

        }

    }
4   Note:

    1. Co-variance and contra-variance is possible only with reference types; value types
    are invariant.

    2. In .NET 4.0, the support for co-variance and contra-variance has been extended to
    generic types. No now we can apply co-variance and contra-variance to Lists etc. (e.g.
    IEnumerable etc.) that implement a common interface. This was not possible with
    .NET versions 3.5 and earlier.
3.Difference between IList and IEnumerable


 S.No    IList                                      IEnumerable
 1       IList is used to access an element in a    IEnumerable is a forward only collection, it
         specific position/index in a list.         can not move backward and between the
                                                    items.
 2       IList is useful when we want to Add or     IEnumerable does not support add or remove
         remove items from the list.                items from the list.
 3       IList can find out the no of elements in   Using IEnumerable we can find out the no of
         the collection without iterating the       elements in the collection after iterating the
         collection.                                collection.
 4       IList does not support filtering.          IEnumerable supports filtering.

4.Difference between IEnumerable and IQueryable


 S.No    IEnumerable                                IQueryable
 1       IEnumerable exists in                      IQueryable exists in System.Linq
         System.Collections Namespace.              Namespace.
 2       IEnumerable is best to query data from     IQueryable is best to query data from out-
         in-memory collections like List, Array     memory (like remote database, service)
         etc.                                       collections.
 3       While query data from database,            While query data from database,
         IEnumerable execute select query on        IEnumerable execute select query on server
         server side, load data in-memory on        side with all filters.
         client side and then filter data.
 4       IEnumerable is suitable for LINQ to         IQueryable is suitable for LINQ to SQL
         Object and LINQ to XML queries.            queries.
 5       IEnumerable does not supports custom       IQueryable supports custom query using
         query.                                     CreateQuery and Execute methods.
 6       IEnumerable does not support lazy          IQueryable support lazy loading. Hence it is
         loading. Hence not suitable for paging     suitable for paging like scenarios.
         like scenarios.
 7       Extension methods supports by              Extension methods supports by IEnumerable
         IEnumerable takes functional objects.      takes expression objects means expression
                                                    tree.
 8       IEnumerable Example

            MyDataContext dc = new MyDataContext ();
            IEnumerable list = dc.loyees.Where(p => p.Name.StartsWith("S"));
            list = list.Take(10);

         Generated SQL statements of above query will be :

            SELECT [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee] AS [t0]
            WHERE [t0].[EmpName] LIKE @p0
Note: In this query "top 10" is missing since IEnumerable filters records on client side


         IQueryable Example

           MyDataContext dc = new MyDataContext ();
           IEnumerable list = dc.loyees.Where(p => p.Name.StartsWith("S"));
           list = list.Take(10);

         Generated SQL statements of above query will be :

           SELECT TOP 10 [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee]
         AS [t0]
          WHERE [t0].[EmpName] LIKE @p0

         Note: In this query "top 10" is exist since IQueryable executes query in SQL server
         with all filters.

5.Difference between IEnumerable and IEnumerator

 S.No    IEnumerable                               IEnumerator
 1       The IEnumerable interface is a generic    IEnumerator provides two abstract methods
         interface that provides an abstraction    and a property to pull a particular element in
         for looping over elements.                a collection. And they are Reset(),
         In addition to providing foreach          MoveNext() and Current The signature of
         support, it allows us to tap into the     IEnumerator members is as follows:
         useful extension methods in the           void Reset() : Sets the enumerator to its
         System.Linq namespace, opening up a       initial position, which is before the first
         lot of advanced functionality             element in the collection.
         The IEnumerable interface contains an     bool MoveNext() : Advances the enumerator
         abstract member function called           to the next element of the collection.
         GetEnumerator() and return an interface   object Current : Gets the current element in
         IEnumerator on any success call.          the collection
 2       IEnumerable does not remember the         IEnumerator does remember the cursor state
         cursor state i.e currently row which is
         iterating through
 3       IEnumerable is useful when we have        IEnumerator is useful when we have to pass
         only iterate the value                    the iterator as parameter and has to remember
                                                   the value

More Related Content

What's hot

Autoboxing And Unboxing In Java
Autoboxing And Unboxing In JavaAutoboxing And Unboxing In Java
Autoboxing And Unboxing In Java
chathuranga kasun bamunusingha
 
The Awesome Python Class Part-2
The Awesome Python Class Part-2The Awesome Python Class Part-2
The Awesome Python Class Part-2
Binay Kumar Ray
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
Rasan Samarasinghe
 
Python The basics
Python   The basicsPython   The basics
Python The basics
Bobby Murugesan
 
What's New In Python 2.5
What's New In Python 2.5What's New In Python 2.5
What's New In Python 2.5
Richard Jones
 
Double pointer (pointer to pointer)
Double pointer (pointer to pointer)Double pointer (pointer to pointer)
Double pointer (pointer to pointer)
sangrampatil81
 
What's New In Python 2.4
What's New In Python 2.4What's New In Python 2.4
What's New In Python 2.4
Richard Jones
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statements
İbrahim Kürce
 
Object oriented concepts & programming (2620003)
Object oriented concepts & programming (2620003)Object oriented concepts & programming (2620003)
Object oriented concepts & programming (2620003)
nirajmandaliya
 
python Function
python Function python Function
python Function
Ronak Rathi
 
Python Closures Explained | What are Closures in Python | Python Closures
Python Closures Explained | What are Closures in Python | Python ClosuresPython Closures Explained | What are Closures in Python | Python Closures
Python Closures Explained | What are Closures in Python | Python Closures
Intellipaat
 
M C6java3
M C6java3M C6java3
M C6java3
mbruggen
 
Chapter 7 String
Chapter 7 StringChapter 7 String
Chapter 7 String
OUM SAOKOSAL
 
05 object behavior
05 object behavior05 object behavior
Advance python
Advance pythonAdvance python
Advance python
pulkit agrawal
 
Python for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.comPython for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.com
ShwetaAggarwal56
 
Python programming
Python  programmingPython  programming
Python programming
Ashwin Kumar Ramasamy
 
DISE - Windows Based Application Development in Java
DISE - Windows Based Application Development in JavaDISE - Windows Based Application Development in Java
DISE - Windows Based Application Development in Java
Rasan Samarasinghe
 
Pointers
PointersPointers
Pointers
Lp Singh
 
Pointers
PointersPointers
Pointers
Joy Forerver
 

What's hot (20)

Autoboxing And Unboxing In Java
Autoboxing And Unboxing In JavaAutoboxing And Unboxing In Java
Autoboxing And Unboxing In Java
 
The Awesome Python Class Part-2
The Awesome Python Class Part-2The Awesome Python Class Part-2
The Awesome Python Class Part-2
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
Python The basics
Python   The basicsPython   The basics
Python The basics
 
What's New In Python 2.5
What's New In Python 2.5What's New In Python 2.5
What's New In Python 2.5
 
Double pointer (pointer to pointer)
Double pointer (pointer to pointer)Double pointer (pointer to pointer)
Double pointer (pointer to pointer)
 
What's New In Python 2.4
What's New In Python 2.4What's New In Python 2.4
What's New In Python 2.4
 
OCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & StatementsOCA Java SE 8 Exam Chapter 2 Operators & Statements
OCA Java SE 8 Exam Chapter 2 Operators & Statements
 
Object oriented concepts & programming (2620003)
Object oriented concepts & programming (2620003)Object oriented concepts & programming (2620003)
Object oriented concepts & programming (2620003)
 
python Function
python Function python Function
python Function
 
Python Closures Explained | What are Closures in Python | Python Closures
Python Closures Explained | What are Closures in Python | Python ClosuresPython Closures Explained | What are Closures in Python | Python Closures
Python Closures Explained | What are Closures in Python | Python Closures
 
M C6java3
M C6java3M C6java3
M C6java3
 
Chapter 7 String
Chapter 7 StringChapter 7 String
Chapter 7 String
 
05 object behavior
05 object behavior05 object behavior
05 object behavior
 
Advance python
Advance pythonAdvance python
Advance python
 
Python for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.comPython for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.com
 
Python programming
Python  programmingPython  programming
Python programming
 
DISE - Windows Based Application Development in Java
DISE - Windows Based Application Development in JavaDISE - Windows Based Application Development in Java
DISE - Windows Based Application Development in Java
 
Pointers
PointersPointers
Pointers
 
Pointers
PointersPointers
Pointers
 

Similar to Dotnet programming concepts difference faqs- 2

Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptx
rohithprabhas1
 
C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And Answer
Jagan Mohan Bishoyi
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answer
lavparmar007
 
python interview prep question , 52 questions
python interview prep question , 52 questionspython interview prep question , 52 questions
python interview prep question , 52 questions
gokul174578
 
computer notes - Reference variables
computer notes -  Reference variablescomputer notes -  Reference variables
computer notes - Reference variables
ecomputernotes
 
Structured Languages
Structured LanguagesStructured Languages
Structured Languages
Mufaddal Nullwala
 
C language presentation
C language presentationC language presentation
C language presentation
bainspreet
 
Improve Your Edge on Machine Learning - Day 1.pptx
Improve Your Edge on Machine Learning - Day 1.pptxImprove Your Edge on Machine Learning - Day 1.pptx
Improve Your Edge on Machine Learning - Day 1.pptx
CatherineVania1
 
GE3151 UNIT II Study material .pdf
GE3151 UNIT II Study material .pdfGE3151 UNIT II Study material .pdf
GE3151 UNIT II Study material .pdf
Asst.prof M.Gokilavani
 
functions- best.pdf
functions- best.pdffunctions- best.pdf
functions- best.pdf
MikialeTesfamariam
 
Lecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops conceptLecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops concept
manish kumar
 
Basic of Python- Hands on Session
Basic of Python- Hands on SessionBasic of Python- Hands on Session
Basic of Python- Hands on Session
Dharmesh Tank
 
Arrays C#
Arrays C#Arrays C#
Arrays in programming
Arrays in programmingArrays in programming
Arrays in programming
TaseerRao
 
Java String
Java String Java String
Java String
SATYAM SHRIVASTAV
 
1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers
Akash Gawali
 
Notes on c++
Notes on c++Notes on c++
Notes on c++
Selvam Edwin
 
Basic_Java_02.pptx
Basic_Java_02.pptxBasic_Java_02.pptx
Basic_Java_02.pptx
Kajal Kashyap
 
functions-.pdf
functions-.pdffunctions-.pdf
functions-.pdf
MikialeTesfamariam
 
Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning
ParrotAI
 

Similar to Dotnet programming concepts difference faqs- 2 (20)

Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptx
 
C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And Answer
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answer
 
python interview prep question , 52 questions
python interview prep question , 52 questionspython interview prep question , 52 questions
python interview prep question , 52 questions
 
computer notes - Reference variables
computer notes -  Reference variablescomputer notes -  Reference variables
computer notes - Reference variables
 
Structured Languages
Structured LanguagesStructured Languages
Structured Languages
 
C language presentation
C language presentationC language presentation
C language presentation
 
Improve Your Edge on Machine Learning - Day 1.pptx
Improve Your Edge on Machine Learning - Day 1.pptxImprove Your Edge on Machine Learning - Day 1.pptx
Improve Your Edge on Machine Learning - Day 1.pptx
 
GE3151 UNIT II Study material .pdf
GE3151 UNIT II Study material .pdfGE3151 UNIT II Study material .pdf
GE3151 UNIT II Study material .pdf
 
functions- best.pdf
functions- best.pdffunctions- best.pdf
functions- best.pdf
 
Lecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops conceptLecture - 3 Variables-data type_operators_oops concept
Lecture - 3 Variables-data type_operators_oops concept
 
Basic of Python- Hands on Session
Basic of Python- Hands on SessionBasic of Python- Hands on Session
Basic of Python- Hands on Session
 
Arrays C#
Arrays C#Arrays C#
Arrays C#
 
Arrays in programming
Arrays in programmingArrays in programming
Arrays in programming
 
Java String
Java String Java String
Java String
 
1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers
 
Notes on c++
Notes on c++Notes on c++
Notes on c++
 
Basic_Java_02.pptx
Basic_Java_02.pptxBasic_Java_02.pptx
Basic_Java_02.pptx
 
functions-.pdf
functions-.pdffunctions-.pdf
functions-.pdf
 
Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning
 

More from Umar Ali

Difference between wcf and asp.net web api
Difference between wcf and asp.net web apiDifference between wcf and asp.net web api
Difference between wcf and asp.net web api
Umar Ali
 
Difference between ActionResult() and ViewResult()
Difference between ActionResult() and ViewResult()Difference between ActionResult() and ViewResult()
Difference between ActionResult() and ViewResult()
Umar Ali
 
Difference between asp.net mvc 3 and asp.net mvc 4
Difference between asp.net mvc 3 and asp.net mvc 4Difference between asp.net mvc 3 and asp.net mvc 4
Difference between asp.net mvc 3 and asp.net mvc 4
Umar Ali
 
Difference between asp.net web api and asp.net mvc
Difference between asp.net web api and asp.net mvcDifference between asp.net web api and asp.net mvc
Difference between asp.net web api and asp.net mvc
Umar Ali
 
Difference between asp.net web forms and asp.net mvc
Difference between asp.net web forms and asp.net mvcDifference between asp.net web forms and asp.net mvc
Difference between asp.net web forms and asp.net mvc
Umar Ali
 
ASP.NET MVC difference between questions list 1
ASP.NET MVC difference between questions list 1ASP.NET MVC difference between questions list 1
ASP.NET MVC difference between questions list 1
Umar Ali
 
Link checkers 1
Link checkers 1Link checkers 1
Link checkers 1
Umar Ali
 
Affiliate Networks Sites-1
Affiliate Networks Sites-1Affiliate Networks Sites-1
Affiliate Networks Sites-1
Umar Ali
 
Technical Video Training Sites- 1
Technical Video Training Sites- 1Technical Video Training Sites- 1
Technical Video Training Sites- 1
Umar Ali
 
US News Sites- 1
US News Sites- 1 US News Sites- 1
US News Sites- 1
Umar Ali
 
How to create user friendly file hosting link sites
How to create user friendly file hosting link sitesHow to create user friendly file hosting link sites
How to create user friendly file hosting link sites
Umar Ali
 
Weak hadiths in tamil
Weak hadiths in tamilWeak hadiths in tamil
Weak hadiths in tamil
Umar Ali
 
Bulughul Maram in tamil
Bulughul Maram in tamilBulughul Maram in tamil
Bulughul Maram in tamil
Umar Ali
 
Asp.net website usage and job trends
Asp.net website usage and job trendsAsp.net website usage and job trends
Asp.net website usage and job trends
Umar Ali
 
Indian news sites- 1
Indian news sites- 1 Indian news sites- 1
Indian news sites- 1
Umar Ali
 
Photo sharing sites- 1
Photo sharing sites- 1 Photo sharing sites- 1
Photo sharing sites- 1
Umar Ali
 
File hosting search engines
File hosting search enginesFile hosting search engines
File hosting search engines
Umar Ali
 
Ajax difference faqs compiled- 1
Ajax difference  faqs compiled- 1Ajax difference  faqs compiled- 1
Ajax difference faqs compiled- 1
Umar Ali
 
ADO.NET difference faqs compiled- 1
ADO.NET difference  faqs compiled- 1ADO.NET difference  faqs compiled- 1
ADO.NET difference faqs compiled- 1
Umar Ali
 
Dotnet differences compiled -1
Dotnet differences compiled -1Dotnet differences compiled -1
Dotnet differences compiled -1
Umar Ali
 

More from Umar Ali (20)

Difference between wcf and asp.net web api
Difference between wcf and asp.net web apiDifference between wcf and asp.net web api
Difference between wcf and asp.net web api
 
Difference between ActionResult() and ViewResult()
Difference between ActionResult() and ViewResult()Difference between ActionResult() and ViewResult()
Difference between ActionResult() and ViewResult()
 
Difference between asp.net mvc 3 and asp.net mvc 4
Difference between asp.net mvc 3 and asp.net mvc 4Difference between asp.net mvc 3 and asp.net mvc 4
Difference between asp.net mvc 3 and asp.net mvc 4
 
Difference between asp.net web api and asp.net mvc
Difference between asp.net web api and asp.net mvcDifference between asp.net web api and asp.net mvc
Difference between asp.net web api and asp.net mvc
 
Difference between asp.net web forms and asp.net mvc
Difference between asp.net web forms and asp.net mvcDifference between asp.net web forms and asp.net mvc
Difference between asp.net web forms and asp.net mvc
 
ASP.NET MVC difference between questions list 1
ASP.NET MVC difference between questions list 1ASP.NET MVC difference between questions list 1
ASP.NET MVC difference between questions list 1
 
Link checkers 1
Link checkers 1Link checkers 1
Link checkers 1
 
Affiliate Networks Sites-1
Affiliate Networks Sites-1Affiliate Networks Sites-1
Affiliate Networks Sites-1
 
Technical Video Training Sites- 1
Technical Video Training Sites- 1Technical Video Training Sites- 1
Technical Video Training Sites- 1
 
US News Sites- 1
US News Sites- 1 US News Sites- 1
US News Sites- 1
 
How to create user friendly file hosting link sites
How to create user friendly file hosting link sitesHow to create user friendly file hosting link sites
How to create user friendly file hosting link sites
 
Weak hadiths in tamil
Weak hadiths in tamilWeak hadiths in tamil
Weak hadiths in tamil
 
Bulughul Maram in tamil
Bulughul Maram in tamilBulughul Maram in tamil
Bulughul Maram in tamil
 
Asp.net website usage and job trends
Asp.net website usage and job trendsAsp.net website usage and job trends
Asp.net website usage and job trends
 
Indian news sites- 1
Indian news sites- 1 Indian news sites- 1
Indian news sites- 1
 
Photo sharing sites- 1
Photo sharing sites- 1 Photo sharing sites- 1
Photo sharing sites- 1
 
File hosting search engines
File hosting search enginesFile hosting search engines
File hosting search engines
 
Ajax difference faqs compiled- 1
Ajax difference  faqs compiled- 1Ajax difference  faqs compiled- 1
Ajax difference faqs compiled- 1
 
ADO.NET difference faqs compiled- 1
ADO.NET difference  faqs compiled- 1ADO.NET difference  faqs compiled- 1
ADO.NET difference faqs compiled- 1
 
Dotnet differences compiled -1
Dotnet differences compiled -1Dotnet differences compiled -1
Dotnet differences compiled -1
 

Recently uploaded

Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
christinelarrosa
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
Mydbops
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
Fwdays
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
christinelarrosa
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
FilipTomaszewski5
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 

Recently uploaded (20)

Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 

Dotnet programming concepts difference faqs- 2

  • 1. 1.Difference between for and foreach loop S.No For loop Foreach loop 1 In case of for the variable of the loop is In case of Foreach the variable of the loop always be int only. while be same as the type of values under the array. 2 The For loop executes the statement or The Foreach statement repeats a group of block of statements repeatedly until embedded statements for each element in an specified expression evaluates to false. array or an object collection. 3 There is need to specify the loop We do not need to specify the loop bounds bounds(Minimum, Maximum). minimum or maximum. 4 example: example: using sytem; using sytem; class class1 class class1 { { static void Main() static void Main() { { int j=0; int j=0; for(int i=0; i<=10;i++) int[] arr=new int[] { {0,3,5,2,55,34,643,42,23}; j=j+1; foreach(int i in arr) } { Console.ReadLine(); j=j+1; } } } Console.ReadLine(); } } 2. Difference between Covariance and Contravariance S.No Covariance Contravariance 1 Converting from a broader type to a Converting from a more specific type to a specific type is called co-variance.If B broader type is called contra-variance. If B is is derived from A and B relates to A, derived from A and B relates to A, then we then we can assign A to B. Like A=B. can assign B to A. Like B= A. This is This is Covariance. Contravariance. 2 Co-variance is guaranteed to work Contra-variance on the other hand is not without any loss of information during guaranteed to work without loss of data. As conversion. So, most languages also such an explicit cast is required. provide facility for implicit conversion. e.g. Converting from cat or dog to animal is e.g. Assuming dog and cat inherits from called contra-variance, because not all animal, when you convert from animal features (properties/methods) of cat or dog is type to dog or cat, it is called co- present in animal. variance. 3 Example:
  • 2. class Fruit { } class Mango : Fruit { } class Program { delegate T Func<out T>(); delegate void Action<in T>(T a); static void Main(string[] args) { // Covariance Func<Mango> mango = () => new Mango(); Func<Fruit> fruit = mango; // Contravariance Action<Fruit> fr = (frt) => { Console.WriteLine(frt); }; Action<Mango> man = fr; } } 4 Note: 1. Co-variance and contra-variance is possible only with reference types; value types are invariant. 2. In .NET 4.0, the support for co-variance and contra-variance has been extended to generic types. No now we can apply co-variance and contra-variance to Lists etc. (e.g. IEnumerable etc.) that implement a common interface. This was not possible with .NET versions 3.5 and earlier.
  • 3. 3.Difference between IList and IEnumerable S.No IList IEnumerable 1 IList is used to access an element in a IEnumerable is a forward only collection, it specific position/index in a list. can not move backward and between the items. 2 IList is useful when we want to Add or IEnumerable does not support add or remove remove items from the list. items from the list. 3 IList can find out the no of elements in Using IEnumerable we can find out the no of the collection without iterating the elements in the collection after iterating the collection. collection. 4 IList does not support filtering. IEnumerable supports filtering. 4.Difference between IEnumerable and IQueryable S.No IEnumerable IQueryable 1 IEnumerable exists in IQueryable exists in System.Linq System.Collections Namespace. Namespace. 2 IEnumerable is best to query data from IQueryable is best to query data from out- in-memory collections like List, Array memory (like remote database, service) etc. collections. 3 While query data from database, While query data from database, IEnumerable execute select query on IEnumerable execute select query on server server side, load data in-memory on side with all filters. client side and then filter data. 4 IEnumerable is suitable for LINQ to IQueryable is suitable for LINQ to SQL Object and LINQ to XML queries. queries. 5 IEnumerable does not supports custom IQueryable supports custom query using query. CreateQuery and Execute methods. 6 IEnumerable does not support lazy IQueryable support lazy loading. Hence it is loading. Hence not suitable for paging suitable for paging like scenarios. like scenarios. 7 Extension methods supports by Extension methods supports by IEnumerable IEnumerable takes functional objects. takes expression objects means expression tree. 8 IEnumerable Example MyDataContext dc = new MyDataContext (); IEnumerable list = dc.loyees.Where(p => p.Name.StartsWith("S")); list = list.Take(10); Generated SQL statements of above query will be : SELECT [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee] AS [t0] WHERE [t0].[EmpName] LIKE @p0
  • 4. Note: In this query "top 10" is missing since IEnumerable filters records on client side IQueryable Example MyDataContext dc = new MyDataContext (); IEnumerable list = dc.loyees.Where(p => p.Name.StartsWith("S")); list = list.Take(10); Generated SQL statements of above query will be : SELECT TOP 10 [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee] AS [t0] WHERE [t0].[EmpName] LIKE @p0 Note: In this query "top 10" is exist since IQueryable executes query in SQL server with all filters. 5.Difference between IEnumerable and IEnumerator S.No IEnumerable IEnumerator 1 The IEnumerable interface is a generic IEnumerator provides two abstract methods interface that provides an abstraction and a property to pull a particular element in for looping over elements. a collection. And they are Reset(), In addition to providing foreach MoveNext() and Current The signature of support, it allows us to tap into the IEnumerator members is as follows: useful extension methods in the void Reset() : Sets the enumerator to its System.Linq namespace, opening up a initial position, which is before the first lot of advanced functionality element in the collection. The IEnumerable interface contains an bool MoveNext() : Advances the enumerator abstract member function called to the next element of the collection. GetEnumerator() and return an interface object Current : Gets the current element in IEnumerator on any success call. the collection 2 IEnumerable does not remember the IEnumerator does remember the cursor state cursor state i.e currently row which is iterating through 3 IEnumerable is useful when we have IEnumerator is useful when we have to pass only iterate the value the iterator as parameter and has to remember the value