SlideShare une entreprise Scribd logo
1  sur  4
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

The Awesome Python Class Part-2
The Awesome Python Class Part-2The Awesome Python Class Part-2
The Awesome Python Class Part-2Binay Kumar Ray
 
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.5Richard 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.4Richard 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 ClosuresIntellipaat
 
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.comShwetaAggarwal56
 
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 JavaRasan Samarasinghe
 

Tendances (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
 

Similaire à Dotnet programming concepts difference faqs- 2

Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptxrohithprabhas1
 
C++ Interview Question And Answer
C++ Interview Question And AnswerC++ Interview Question And Answer
C++ Interview Question And AnswerJagan Mohan Bishoyi
 
C++ questions And Answer
C++ questions And AnswerC++ questions And Answer
C++ questions And Answerlavparmar007
 
python interview prep question , 52 questions
python interview prep question , 52 questionspython interview prep question , 52 questions
python interview prep question , 52 questionsgokul174578
 
computer notes - Reference variables
computer notes -  Reference variablescomputer notes -  Reference variables
computer notes - Reference variablesecomputernotes
 
C language presentation
C language presentationC language presentation
C language presentationbainspreet
 
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.pptxCatherineVania1
 
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 conceptmanish kumar
 
Basic of Python- Hands on Session
Basic of Python- Hands on SessionBasic of Python- Hands on Session
Basic of Python- Hands on SessionDharmesh Tank
 
Arrays in programming
Arrays in programmingArrays in programming
Arrays in programmingTaseerRao
 
1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answers1183 c-interview-questions-and-answers
1183 c-interview-questions-and-answersAkash Gawali
 
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
 

Similaire à 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
 

Plus de 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 apiUmar 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 4Umar 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 mvcUmar 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 mvcUmar 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 1Umar Ali
 
Link checkers 1
Link checkers 1Link checkers 1
Link checkers 1Umar Ali
 
Affiliate Networks Sites-1
Affiliate Networks Sites-1Affiliate Networks Sites-1
Affiliate Networks Sites-1Umar Ali
 
Technical Video Training Sites- 1
Technical Video Training Sites- 1Technical Video Training Sites- 1
Technical Video Training Sites- 1Umar 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 sitesUmar Ali
 
Weak hadiths in tamil
Weak hadiths in tamilWeak hadiths in tamil
Weak hadiths in tamilUmar Ali
 
Bulughul Maram in tamil
Bulughul Maram in tamilBulughul Maram in tamil
Bulughul Maram in tamilUmar 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 trendsUmar 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 enginesUmar Ali
 
Ajax difference faqs compiled- 1
Ajax difference  faqs compiled- 1Ajax difference  faqs compiled- 1
Ajax difference faqs compiled- 1Umar Ali
 
ADO.NET difference faqs compiled- 1
ADO.NET difference  faqs compiled- 1ADO.NET difference  faqs compiled- 1
ADO.NET difference faqs compiled- 1Umar Ali
 
Dotnet differences compiled -1
Dotnet differences compiled -1Dotnet differences compiled -1
Dotnet differences compiled -1Umar Ali
 

Plus de 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
 

Dernier

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Dernier (20)

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

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