{"id":19361404,"url":"https://github.com/kansiris/c-sharp-c-interview-question","last_synced_at":"2025-02-24T12:25:02.186Z","repository":{"id":41434143,"uuid":"195598500","full_name":"kansiris/C-Sharp-c-interview-question","owner":"kansiris","description":"List of top 500 C# csharp Interview Questions \u0026 Answers....Coding exercise questions are coming soon!!","archived":false,"fork":false,"pushed_at":"2021-10-31T13:39:51.000Z","size":415,"stargazers_count":155,"open_issues_count":1,"forks_count":39,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-06T19:43:00.123Z","etag":null,"topics":["interview-practice","interview-questions","namespace-sampleprogram","programming-languages"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kansiris.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-07T01:41:15.000Z","updated_at":"2025-01-04T03:57:31.000Z","dependencies_parsed_at":"2022-08-10T02:23:42.235Z","dependency_job_id":null,"html_url":"https://github.com/kansiris/C-Sharp-c-interview-question","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kansiris%2FC-Sharp-c-interview-question","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kansiris%2FC-Sharp-c-interview-question/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kansiris%2FC-Sharp-c-interview-question/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kansiris%2FC-Sharp-c-interview-question/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kansiris","download_url":"https://codeload.github.com/kansiris/C-Sharp-c-interview-question/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240476344,"owners_count":19807501,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interview-practice","interview-questions","namespace-sampleprogram","programming-languages"],"created_at":"2024-11-10T07:22:55.628Z","updated_at":"2025-02-24T12:25:02.156Z","avatar_url":"https://github.com/kansiris.png","language":null,"readme":"# CSHARP C# Interview Questions \u0026 Answers\n\n\u003e Click :star:if you like the project. Pull Request are highly appreciated. Follow me [@kansiris87](https://twitter.com/kansiris87) for technical updates.\n\n### Table of Contents\n\n| No. | Questions |\n|---- | ---------|\n|1    | [What is Computer programming?\t](# )|\n|2    | [How programming work?\t](# )|\n|3    | [What is debugging?\t](# )|\n|4    | [Name different types errors which can occur during the execution of a program?\t](# )|\n|5  | [When a syntax error occurs?\t](# )|\n|6    | [When a runtime error occurs?\t](# )|\n|7    | [When a logical error occurs? ](# )|\n|8    | [What is flowchart?\t](# )|\n|9    | [What is an algorithm?\t](# )|\n|10    | [What do you understand by the term 'Maintain and update the Program'? ](# )|\n|11    | [What are variables?\t](# )|\n|12    | [What are reserved words?\t](# )|\n|13    | [What are Loop?\t](# )|\n|14    | [What is the use of FOR…NEXT Loop? ](# )|\n|15    | [What is the use of WHILE…WEND Loop?\t](# )|\n|16    | [What is the use of Nested Loop?\t](# )|\n|17    | [What is Documentation?\t](# )|\n|18    | [What is the working of a compiler?\t](# )|\n|19    | [What do we call the binary form of a target language?\t](# )|\n|10    | [What are constants?\t](# )|\n|21    | [Define Numeric constants.\t](# )|\n|22    | [Define String constants.\t](# )|\n|23    | [Define Operators.\t](# )|\n|24    | [What is an Array?\t](# )|\n|25    | [What is subroutine?\t](# )|\n|26    | [What is the purpose of arithmetic operators?\t](# )|\n|27    | [What is the purpose of relational operators?\t](# )|\n|28   | [Define Low-level programming language.\t](# )|\n|29    | [Define High-Level programming language.\t](# )|\n|30    | [What is Machine code?\t](# )|\n|31    | [List some programming languages.\t](# )|\n|32    | [What is reliability?\t](# )|\n|3503    | [What is modeling language?\t](# )|\n|34    | [Name some modeling languages? ](# )|\n|35    | [What is software testing?\t](# )|\n|36   | [What is Beta version?\t](# )|\n|37    | [What is the working of logical operators?\t ](# )|\n|38    | [What is the purpose of assignment operator? ](# )|\n|39   | [What is analyzing a program?\t](# )|\n|40   | [What is the working on an algorithm?\t](# )|\n|41    | [How is the division by zero defined?\t](# )|\n|42    | [What is the meaning of implementation of a program?\t](# )|\n|43    | [What are numeric variables?\t](# )|\n|44    | [What are string variables?\t](# )|\n|45   | [What are commands?\t](# )|\n|46   | [What are statements?\t](# )|\n|47    | [What is the execution of a program?\t](# )|\n|48    | [Define variable and constant.\t](# )|\n|49   | [What is a data type? How many types of data types are there in .NET ?\t](# )|\n|50   | [Mention the two major categories that distinctly classify the variables of C# programs.\t](# )|\n|51    | [Which statement is used to replace multiple if-else statements in code.\t](# )|\n|52    | [What is the syntax to declare a namespace in .NET?\t](# )|\n|53    | [Differentiate between the while and for loop in C#.\t](# )|\n|54    | [What is an identifier?\t](# )|\n|55    | [What does a break statement do in the switch statement?\t](# )|\n|56    | [Explain keywords with example.\t](# )|\n|57    | [Briefly explain the characteristics of value-type variables that are supported in the C# programming language.\t](# )|\n|58    | [What is a parameter? Explain the new types of parameters introduced in C# 4.0.\t](# )|\n|59    | [Briefly explain the characteristics of reference-type variables that are supported in the C# programming language.\t](# )|\n|60   | [What are the different types of literals?\t](# )|\n|61    | [What is the main difference between sub-procedure and function?\t](# )|\n|62   | [Differentiate between Boxing and Unboxing. ](# )|\n|63   | [What is C#?\t](# )|\n|64    | [What is an Object?\t](# )|\n|65   | [What is the difference between a struct and a class in C#?\t](# )|\n|66   | [What is the difference between Interface and Abstract Class?\t](# )|\n|67   | [What is enum in C#?\t](# )|\n|68   | [What is the difference between “continue” and “break” statements in C#?\t](# )|\n|69   | [What is the difference between constant and readonly in c#?\t](# )|\n|70   | [What is the difference between ref and out keywords?\t](# )|\n|71    | [Can “this” be used within a static method?\t](# )|\t\n|72    | [Define Property in C# .net?\t](# )|\n|73   | [What is extension method in c# and how to use them?\t](# )|\n|74   | [What is the difference between string and StringBuilder in c#?\t](# )|\n|75   | [What are delegates in C# and uses of delegates?\t](# )|\n|76   | [What is sealed class in c#?\t](# )|\n|77   | [ What are partial classes?\t](# )|\n|78   | [ What is IEnumerable\u003c\u003e in c#?\t](# )|\n|79   | [ What is difference between late binding and early binding in c#?\t](# )|\n|80   | [What are the differences between IEnumerable and IQueryable?\t](# )|\n|81    | [What happens if the inherited interfaces have conflicting method names?\t](# )|\n|82    | [What are the Arrays in C#.Net?\t](# )|\n|83   | [What is the Constructor Chaining in C#?\t](# )|\n|84   | [What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?\t](# )|\n|85   | [Can Multiple Catch Blocks executed in c#?\t](# )|\n|86   | [Difference between Throw Exception and Throw Clause.\t](# )|\n|87   | [What is Indexer in C# .Net?\t](# )|\n|88   | [What is multicast delegate in c#?\t](# )|\n|89   | [Difference between Equality Operator (==) and Equals() Method in C#.\t](# )|\n|90   | [Difference between “is” and “as” operator in C#.\t](# )|\n|91   | [How to use Nullable\u003c\u003e Types in .Net?\t](# )|\n|92   | [Different Ways of Method can be overloaded.\t](# )|\n|93   | [What is an Object Pool in .Net?\t](# )|\n|94   | [What are generics in c#.net?\t](# )|\n|95   | [Describe the accessibility modifiers in c#.Net\t](# )|\n|96   | [What is Virtual Method in C#?\t](# )|\n|97   | [What is the Difference between Array and ArrayList in C#.Net?\t](# )|\n|98   | [What you understand by Value types and Reference types in C#.Net?\t](# )|\n|99   | [What is Serialization?\t](# )|\n|100   | [What is the use of using statement in C#?\t](# )|\n|101  | [What is jagged array in C#.Net?\t](# )|\n|102    | [What is Multithreading with .NET?\t](# )|\n|103    | [Explain Anonymous type in C#?\t](# )|\n|104    | [Explain Hashtable in C#?\t](# )|\n|105    | [What is LINQ in C#?\t](# )|\n|106    | [What is File Handling in C#.Net?\t](# )|\n|107    | [What is Reflection in C#.Net?\t](# )|\n|108    | [What is Expression Trees In C#?\t](# )|\n|109  | [Differences between Object, Var and Dynamic type?\t](# )|\n|110  | [What are OOPS Concepts?\t](# )|\n|111    | [How can you implement multiple inheritance in C#?\t](# )|\n|112    | [Are private class members inherited to the derived class?\t](# )|\n|113    | [When and why to use method overloading\t](# )|\n|114    | [Does C# support multiple-inheritance?\t](# )|\n|115    | [Where is a protected class-level variable available?\t](# )|\n|116    | [Are private class-level variables inherited?\t](# )|\n|117    | [Describe the accessibility modifier “protected internal”.\t](# )|\n|118    | [Which class is at the top of .NET class hierarchy?\t](# )|\n|119    | [What does the term immutable mean?\t](# )|\n|120    | [Can you store multiple data types in System.Array?\t](# )|\n|121    | [What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?\t](# )|\n|122    | [How can you sort the elements of the array in descending order?\t](# )|\n|123    | [What’s the .NET collection class that allows an element to be accessed using a unique key? ](# )|\n|124    | [What class is underneath the Sorted List class?\t](# )|\n|125    | [Will the finally block get executed if an exception has not occurred?\t](# )|\n|126    | [What’s the C# syntax to catch any possible exception?\t](# )|\n|127    | [Can multiple catch blocks be executed for a single try statement?\t](# )|\n|128    | [Explain the three services model commonly know as a three-tier application?\t](# )|\n|129    | [What is the syntax to inherit from a class in C#?\t](# )|\n|130    | [Can you prevent your class from being inherited by another class?\t](# )|\n|131    | [Can you allow a class to be inherited, but prevent the method from being over-ridden?\t](# )|\n|132    | [When do you absolutely have to declare a class as abstract?\t](# )|\n|133    | [Why can’t you specify the accessibility modifier for methods inside the interface?\t ](# )|\n|134    | [Can you inherit multiple interfaces?\t](# )|\n|135    | [ What happens if you inherit multiple interfaces and they have conflicting method names? ](# )|\n|136    | [What’s the implicit name of the parameter that gets passed into the set method/property of a class?\t](# )|\n|137    | [Can you declare an override method to be static if the original method is not static?\t](# )|\n|138    | [What are the different ways a method can be overloaded?\t](# )|\n|139    | [If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?\t](# )|\n|140    | [ What’s the implicit name of the parameter that gets passed into the class’ set method?\t](# )|\n|141    | [How do you inherit from a class in C#?\t](# )|\n|142    | [Does C# support multiple inheritance?\t](# )|\n|143    | [ When you inherit a protected class-level variable, who is it available to?\t](# )|\n|144    | [ Are private class-level variables inherited?\t](# )|\n|145    | [ Describe the accessibility modifier protected internal.?\t](# )|\n|146    | [C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write?\t](# )|\n|147    | [What’s the top .NET class that everything is derived from?\t](# )|\n|148    | [What does the keyword virtual mean in the method definition?\t](# )|\n|149    | [Can you declare the override method static while the original method is non-static?\t](# )|\n|150    | [Can you override private virtual methods?\t](# )|\n|151    | [When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)?\t](# )|\n|152    | [Why can’t you specify the accessibility modifier for methods inside the interface?\t](# )|\n|153    | [And if they have conflicting method names?\t](# )|\n|154    | [If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor?\t](# )|\n|155    | [Is it namespace class or class namespace?\t](# )|\n|156    | [What is the difference between ToString() and Convert.ToString()?\t](# )|\n|157    | [What is the Difference between int.Parse() and Convert.ToInt32()?\t](# )|\n|158    | [What is checked block and unchecked block?\t](# )|\n|159    | [Write a program to get the range of Byte Datatype?\t](# )|\n|160    | [What is the difference between typeOf() and sizeOf()?\t](# )|\n|161    | [What is widening and Narrowing?\t](# )|\n|162    | [How to view an Assembly?\t](# )|\n|163    | [How to implement Reflection in .Net?\t](# )|\n|164    | [What are MultiLingual Applications?\t](# )|\n|165    | [What is the difference between = and ==\t](# )|\n|166    | [What is the use of Codesnippets?\t](# )|\n|167    | [What is the difference between Array and Collections?\t](# )|\n|168    | [What is the default Accessmodifier for the members of the class?\t](# )|\n|169    | [What is the use of constructor?\t](# )|\n|170    | [When the static constructor will be called?\t](# )|\n|171    | [ Can we declare Public accessmodifier for static constructor?\t](# )|\n|172    | [if we declare Main() and static constructor in the same class  which one will be called first?](# )|\n|173    | [How to Call the Default constructor of one class with the parameterised constructor of same class?\t](# )|\n|174    | [How to access the constructors of one class to another class?\t](# )|\n|175    | [Does C#.net Supports Multiple inheritance?\t](# )|\n|176    | [How to acheive Multiple inheritance in C#.NET?\t](# )|\n|177    | [what is OverLoading?\t](# )|\n|178    | [what is Overriding?\t](# )|\n|179    | [what is use of Properties?\t](# )|\n|180    | [what is the Difference between Event and Method?\t](# )|\n|181    | [what are Generics?\t](# )|\n|182    | [Does generics supports Arthimetic Operators ?\t](# )|\n|183    | [what is Dynamic Dispatch?\t](# )|\n|184    | [Which of the following are Build in generic Types?\t](# )|\n|185    | [In .net for Assemblies we are having StrongName lly in COM Components  what is the Strongname?\t](# )|\n|186    | [Is Versioning applicable to Private assemblies?\t](# )|\n|187    | [Does .net supports Cross Language Interoparability in CAS?\t](# )|\n|188    | [What is the importance of “this”keyword? ](# )|\n|189    | [C# program to print prime numbers\t](# )|\n|190    | [C# program to print even numbers\t](# )|\n|191    | [C# program to print fibonacci series](# )|\n|192    | [Palindrome program in C#\t](# )|\n|193    | [Armstrong Number in C#\t ](# )|\n|194    | [C# Program to reverse number\t](# )|\n|195    | [C# Program to generate Fibonacci Triangle\t](# )|\n|196    | [C# Program to Convert Number in Characters\t](# )|\n|197    | [C# Program to print Number Triangle\t](# )|\n|198    | [C# Program to swap two numbers without third variable\t](# )|\n|199    | [Program 2: Using + and -\t](# )|\n|200    | [Decimal to Binary Conversion Algorithm](# )|\n|201    | [C# Program to Convert Number in Characters\t](# )|\n|202    | [C# program to print multiplication table\t](# )|\n|203   | [C# program to print alphabets\t](# )|\n|204  | [Power function in C#\t](# )|\n|205   | [C# program to count emails by domain\t](# )|\n|206  | [Reverse characters in a string\t](# )|\n|207   | [C# program to sort names in ascending and descending order\t](# )|\n|208  | [C# program to remove duplicates\t](# )|\n|209  | [Insert space before every upper case letter in a string\t](# )|\n|210  | [Write a c# program to add two numbers.\t](# )|\n|211  | [Find smallest and largest number in an integer array\t](# )|\n|212  | [C# Program to compute factorial of a number\t](# )|\n|213  | [How to get the total number of decimal places using c#\t](# )|\n|214  | [How to remove trailing zeros in a decimal - C# Program?\t](# )|\n|215  | [Write a c program to print M pattern?] (# )|\n|216  | [Write the o/p for the below program?\t](# )|\n\n\n\n# PROGRAMMING CONCEPT\n\n### What is Computer programming?\n\nComputer Programming is also known as programming or coding. Programming is a process which includes processes such as coding, maintaining, updating, debugging, writing, designing (algorithm), etc.\n\n### How programming work?\n\nProgramming contains a set of instructions for the computer to perform different tasks. In fact, those instructions are executable commands, each having a different purpose.\n\n### What is debugging?\n\nDebugging is the process of finding and removing errors in a program. In this process, the program is thoroughly checked for errors. Then errors are pointed out and debugged.\n\n### Name different types errors which can occur during the execution of a program?\n\nThere are three types of errors which can occur during the execution of a program.\n\nSyntax Errors\n\nRuntime Errors\n\nLogical errors\n\n### When a syntax error occurs?\n\nA syntax error occurs when the program violates one or more grammatical rules of the programming language. These errors are detected at compile time, i.e., when the translator (compiler or interpreter) attempts to translate the program.\n\n### When a runtime error occurs?\n\nA runtime error occurs when the computer is directed to perform an illegal operation by the program such as dividing a number by zero. Runtime errors are the only errors which are displayed immediately during the execution of a program. When these errors occur, the computer stops the execution of the programming and can display a diagnostic message that will help in locating the error.\n\n### When a logical error occurs?\n\nThe logical error happens when a program implements a wrong logic. The translator (compiler or interpreter) does not report any error message for a logical error. These errors are the most difficult to locate.\n\n###  What is flowchart?\n\nThe flowchart is a pictorial representation of a program which helps in understanding the flow of control and data in the algorithm.\n\n### Question: What is an algorithm?\n\nAn algorithm is a finite set of steps which, if followed, accomplish a particular task. An algorithm must be clear, finite and effective.\n\n### Question: What do you understand by the term 'Maintain and update the Program'?\n\nProgram maintenance is an ongoing process of upgrading the program to accommodate new hardware or software requirements and introducing minor or great improvements. Essentially, it is the expansion, updating and improvement of a program after its installation.\n\n### Question: What are variables?\n\nVariables are named memory locations (memory cells) which are used to store program’s input and its computational results during program execution. As the name suggests, the value of a variable may change during the program execution.\n\n### Question: What are reserved words?\n\nReserved words or keywords are the words, which have predefined meanings. They have predefined uses and cannot be used or redefined for any other purpose in a programming language.\n\nExamples\n\nIF\n\nELSE\n\nTHEN\n\n### Question: What are Loop?\n\nThe loop is a structure which can repeat a set of statements up to a fixed number of times or until a certain criterion is satisfied.\nName different types of loops\n\nDifferent types of loops are\n\nFOR…NEXT Loop\n\nWHILE…WEND Loop\n\nNested Loop\n\n### Question: What is the use of FOR…NEXT Loop?\n\nWhen it is known in advance how many times the loop must be repeated the FOR…NEXT Loop is the most effective option. FOR…NEXT Loop is used to repeat a set of statements to a specific number of times.\n\n### Question: What is the use of WHILE…WEND Loop?\n\nThe While loop keeps repeating an action until an associated condition becomes false. This is useful where the programmer does not know in advance how many times the loop will be executed.\n\n### Question: What is the use of Nested Loop?\n\nLoop within a loop is called nested loop.\n\ndetails%3Fid%3Din.togetu\n\n### Question: What is Documentation?\n\nDocumentation is a detailed description of a program’s algorithm, design, coding method, testing, and proper usage. Documentation is valuable for the users who rely upon the program on a day-to-day basis, and for the programmer who may be called on to modify or update it.\n\n### Question: What is the working of a compiler?\n\nA compiler is a unique program that can process statements which are written in a particular programming language and can turn them into machine language or 'code'. This is the working of a complier.\n\n### Question: What do we call the binary form of a target language?\n\nThe binary form of a target language is also called 'Binary Code'.\n\n### Question: What are constants?\n\nA constant is a quantity whose value cannot be changed. Unlike a variable, the value stored in a constant can’t be modified during program execution.\n\nName two types of constants.\n\nTwo types of constants are mentioned below:\n\nNumeric Constants\n\nString Constants\n\n### Question: Define Numeric constants.\n\nNumeric constants consist of integers, single precision, or double-precision numbers. Integer constants represent values that are counted and do not have a fractional part, e.g., +56, -678\n\n### Question: Define String constants.\n\nA string constant is a sequence of alphanumeric characters enclosed in double quotation marks. The maximum length of a string constant is 255 characters. For example, 'New York'\n\n### Question: Define Operators.\n\nOperators are symbols which are used to perform certain operations on a data. These include arithmetic, relational, logical, and assignment operators.\n\n### Question: What is an Array?\n\nAn array is a collection of contiguous memory locations which can store data of the same type.\n\n\n### Question: What is subroutine?\n\nA subroutine is a self-contained set of statements that can be used from anywhere in a program. The subroutine performs its specific task and then returns control to the program that calls the subroutine.\n\n### Question: What is the purpose of arithmetic operators?\n\nArithmetic operators are used to perform arithmetic operations on values (numbers).\n\n### Question: What is the purpose of relational operators?\n\nRelational operators are used to compare two values. These operators always evaluate to true or false. They always produce a non-zero  value (in most case 1).\n\n### Question: Define Low-level programming language.\n\nIn computer programming, the programming language which provides no generalization from the computer’s 'instruction set architecture' is called a low-level programming language. It usually directs to machine code or assembly language.\n\n### Question: Define High-Level programming language.\n\nIn computer programming, the programming language which provides high generalization from the computer’s 'instruction set architecture' is called a high-level programming language. To make the development of a program easier as compared to a low-level programming language, it may use the natural language elements.\n\n### Question: What is Machine code?\n\nMachine code is a language, which can be processed directly by a microprocessor without any need of the previous transformation. Programmers never write programs directly in machine code.\n\nWrite a code in 32-bit x86 machine code to calculate the nth Fibonacci number.\n8B542408 83FA0077 06B80000 0000C383FA027706 B8010000 00C353BB 01000000B9010000 008D0419 83FA0376 078BD98BC84AEBF1 5BC3\n\n### Question: List some programming languages.\n\nSome programming languages are listed below:\n\nA+\n\nA++\n\nACC\n\nALF\n\nAPL\n\nBASIC\n\nCOBOL\n\n### Question: What is reliability?\n\nIt is the proper working of software during a specific period of time. If a program doesn’t work properly during required period then it’s not reliable.\n\n### Question: What is modeling language?\n\nAn artificial language that can be used to express information or knowledge or systems in an arrangement which is defined by a reliable number of rules. These rules are also used for interpretation of the meaning of components in the structure.\n\n### Question: Name some modeling languages.\n\nNames of some modeling languages are listed below:\n\nBusiness Process Modeling Notation\n\nEXPRESS\n\nExtended Enterprise Modeling Language\n\nFlowchart\n\nFundamental Modeling Concepts\n\nJackson Structured Programming\n\nUnified Modeling Language\n\nAlloy (specification language\n\nSystems Modeling Language\n\n### Question: What is software testing?\n\nSoftware testing a process in which software is tested under certain conditions to test the quality of a program. Testing a program is also required to check whether the software provides a good user experience or not.\nTell a few reasons of software testing.\n\nA few reasons for software testing are mentioned below:\n\nProper working\n\nSatisfying quality\n\nFulfills the requirements of the user\n\nCan be implemented with the identical\n\n\n### Question: What is Beta version?\n\nThe beta version of software is that version which is not ready for release and can be changed after the feedback from the users. Beta version comes after alpha version.\n\n### Question: What is the working of logical operators?\n\nLogical operators let us combine simple conditions to construct more complex ones (By conditions, we mean an expression evaluating to true or false).\n\n### Question: What is the purpose of assignment operator?\n\nThe assignment operator is used to store a value, string or a computational result in a variable.\n\n### Question: What is analyzing a program?\n\nThe process in which program is decomposed into sub-problems. Rather on concentrating the bigger problem as a whole, we try to solve each sub-problem separately. This leads to a simple solution. This technique is also known as top-down design.\n\n### Question: What is the working on an algorithm?\n\nEvery algorithm performs at least following three steps:\n\nGet data\n\nPerform computation\n\nDisplay results\n\n### Question: How is the division by zero defined?\n\nDivision by zero is undefined.\n\n### Question: What is the meaning of implementation of a program?\n\nOnce the program has been tested thoroughly, it must be installed or put into operation at the site where it will be used. This is known as an implementation of the program.\n\n### Question: What are numeric variables?\n\nThe variables which can store numeric values are called number variables. Numeric values include both floating point numbers and whole numbers.\n\n### Question: What are string variables?\n\nA string can be defined as a sequence of characters enclosed in double quotations. A string variable can, therefore, store a sequence of characters. The nature of character string is entirely different from the nature of numeric values.\n\n### Question: What are commands?\n\nCommands are executable instructions which are operated in the direct mode. They do not require a preceding line number\n\n### Question: What are statements?\n\nStatements are written as a program, and each statement is preceded by a line number\n\n### Question: What is the execution of a program?\n\nExecution of the program refers to carrying out the instruction of the program. The program must be loaded into memory (RAM) before execution.\n\n### Question: Define variable and constant.\n\nA variable can be defined as a meaningful name that is given to a data storage location in the computer memory that contains a value. Every variable associated with a data type determines what type of value can be stored in the variable, for example an integer, such as 100, a decimal, such as 30.05, or a character, such as 'A'. \n\nYou can declare variables by using the following syntax: \n\n\u003cData_type\u003e \u003cvariable_name\u003e ; \n\nA constant is similar to a variable except that the value, which you assign to a constant, cannot be changed, as in case of a variable. \n\nConstants must be initialized at the same time they are declared. You can declare constants by using the following syntax: \n\nconst int interestRate = 10;\n\n### Question: What is a data type? How many types of data types are there in .NET ?\n\nA data type is a data storage format that can contain a specific type or range of values. Whenever you declare variables, each variable \nmust be assigned a specific data type. Some common data types include integers, floating point, characters, and strings. The following \nare the two types of data types available in .NET: \n\nValue type - Refers to the data type that contains the data. In other words, the exact value or the data is directly stored in this data type. It means that when you assign a value type variable to another variable, then it copies the value rather than copying the reference of that variable. When you create a value type variable, a single space in memory is allocated to store the value (stack memory). Primitive data types, such as int, float, and char are examples of value type variables. \n\nReference type - Refers to a data type that can access data by reference. Reference is a value or an address that accesses a particular data by address, which is stored elsewhere in memory (heap memory). You can say that reference is the physical address of data, where the data is stored in memory or in the storage device. Some built-in reference types variables in .Net are string, array, and object.\n\n### Question: Mention the two major categories that distinctly classify the variables of C# programs.\n\nVariables that are defined in a C# program belong to two major categories: value type and reference type. The variables that are based on value type contain a value that is either allocated on a stack or allocated in-line in a structure. The variables that are based on reference types store the memory address of a variable, which in turn stores the value and are allocated on the heap. The variables that are based on value types have their own copy of data and therefore operations done on one variable do not affect other variables. The reference-type variables reflect the changes made in the referring variables. \n\nPredict the output of the following code segment: \n \nint x = 42; \nint y = 12;  \nint w;  \nobject o;  \no = x;  \nw = y * (int)o;  \nConsole.WriteLine(w);  \n \n/* The output of the code is 504. */\n\n### Question: Which statement is used to replace multiple if-else statements in code.\n\nIn Visual Basic, the Select-Case statement is used to replace multiple If - Else statements and in C#, the switch-case statement is used to replace multiple if-else statements.\n\n### Question: What is the syntax to declare a namespace in .NET?\n\nIn .NET, the namespace keyword is used to declare a namespace in the code. \nThe syntax for declaring a namespace in C# is: \n\nnamespace UserNameSpace; \n\nThe syntax for declaring a namespace in VB is: \n\nNamespace UserNameSpace\n\n### Question: Differentiate between the while and for loop in C#.\n\nThe while and for loops are used to execute those units of code that need to be repeatedly executed, unless the result of the specified condition evaluates to false. The only difference between the two is in their syntax. The for loop is distinguished by setting an explicit loop variable.\n\n### Question: What is an identifier?\n\nIdentifiers are northing but names given to various entities uniquely identified in a program. The name of identifiers must differ in spelling or casing. For example, MyProg and myProg are two different identifiers. Programming languages, such as C# and Visual Basic, strictly restrict the programmers from using any keyword as identifiers. Programmers cannot develop a class whose name is public, because, public is a keyword used to specify the accessibility of data in programs.\n\n### Question: What does a break statement do in the switch statement?\n\nThe switch statement is a selection control statement that is used to handle multiple choices and transfer control to the case statements within its body. The following code snippet shows an example of the use of the switch statement in C#: \n\nswitch(choice) \n{ \n case 1: \n console.WriteLine(First); \n break; \n case 2: \n console.WriteLine(Second); \n break; \n default: \n console.WriteLine(Wrong choice); \n break; \n} \n \nIn switch statements, the break statement is used at the end of a case statement. The break statement is mandatory in C# and it avoids the fall through of one case statement to another.\n\n### Question: Explain keywords with example.\n\nKeywords are those words that are reserved to be used for a specific task. These words cannot be used as identifiers. You cannot use a keyword to define the name of a variable or method. Keywords are used in programs to use the features of object-oriented programming. \nFor example, the abstract keyword is used to implement abstraction and the inherits keyword is used to implement inheritance by deriving subclasses in C# and Visual Basic, respectively. \n\nThe new keyword is universally used in C# and Visual Basic to implement encapsulation by creating objects.\n\n### Question: Briefly explain the characteristics of value-type variables that are supported in the C# programming language.\n\nThe variables that are based on value types directly contain values. The characteristics of value-type variables that are supported in C# programming language are as follows: \n\n1.All value-type variables derive implicitly from the System.ValueTypeclass \n\n2.You cannot derive any new type from a value type \n\n3.Value types have an implicit default constructor that initializes the default value of that type \n\n4.The value type consists of two main categories: \n\ni.Structs - Summarizes small groups of related variables. \n\nii.Enumerations - Consists of a set of named constants.\n\nGive the syntax of using the while loop in a C# program.\n\nThe syntax of using the while loop in C# is: \n\nint i = 0; \n\nwhile(i \u003c 5) //condition \n\n{ \n\nConsole.WriteLine({ 0 }, i); //statements \n\ni++; \n\n} \n\n\no/p: 0 1 2 3 4\n\n### Question: What is a parameter? Explain the new types of parameters introduced in C# 4.0.\n\nA parameter is a special kind of variable, which is used in a function to provide a piece of information or input to a caller function. These inputs are called arguments. In C#, the different types of parameters are as follows: \n\n1.Value type - Refers that you do not need to provide any keyword with a parameter. \n\n2.Reference type - Refers that you need to mention the ref keyword with a parameter. \n\n3.Output type - Refers that you need to mention the out keyword with a parameter. \n\n4.Optional parameter - Refers to the new parameter introduced in C# 4.0. It allows you to neglect the parameters that have some \n\npredefined default values. The example of optional parameter is as follows: \n - public int Sum(int a, int b, int c = 0, int d = 0); /* c and d is optional */ \n - Sum(10, 20); //10 + 20 + 0 + 0 \n - Sum(10, 20, 30); //10 + 20 + 30 + 0 \n - Sum(10, 20, 30, 40); //10 + 20 + 30 + 40 \n \n5.    Named parameter - Refers to the new parameter introduced in C# 4.0. Now you can provide arguments by name rather than position. \n\nThe example of the named parameter is as follows: - public void CreateAccount(string name, string address = unknown, int age = 0); \n\n- CreateAccount(KANSIRIS, age: 30); \n\n- CreateAccount(address: India, name: KANSIRIS);\n\n### Question: Briefly explain the characteristics of reference-type variables that are supported in the C# programming language.\n\nThe variables that are based on reference types store references to the actual data. The keywords that are used to declare reference types are: \n\n1.Class - Refers to the primary building block for the programs, which is used to encapsulate variables and methods into a single unit. \n\n2.Interface - Contains only the signatures of methods, properties, events, or indexers. \n\n3.Delegate - Refers to a reference type that is used to encapsulate a named or anonymous method.\n\n### Question: What are the different types of literals?\n\nA literal is a textual representation of a particular value of a type. \n\nThe different types of literals in Visual Basic are: \n\n1.Boolean Literals - Refers to the True and False literals that map to the true and false state, respectively. \n\n2.Integer Literals - Refers to literals that can be decimal (base 10), hexadecimal (base 16), or octal (base 8). \n\n3.Floating-Point Literals - Refers to an integer literal followed by an optional decimal point By default, a floating-point literal is \nof type Double. \n\n4.String Literals - Refers to a sequence of zero or more Unicode characters beginning and ending with an ASCII double-quote character. \n\n5.Character Literals - Represents a single Unicode character of the Char type. \n\n6.Date Literals - Represents time expressed as a value of the Date type. \n\n7.Nothing - Refers to a literal that does not have a type and is convertible to all types in the type system. \n\n\nThe different types of literals in C# are: \n\n1.Boolean literals - Refers to the True and False literals that map to the true and false states, respectively. \n\n2.Integer literals - Refers to literals that are used to write values of types int, uint, long, and ulong. \n\n3.Real literals - Refers to literals that are used to write values of types float, double, and decimal. \n\n4.Character literals - Represents a single character that usually consists of a character in quotes, such as 'a'. \n\n5.String literals - Refers to string literals, which can be of two types in C#: \n\ni. A regular string literal consists of zero or more characters enclosed in double quotes, such as hello. \n\nii. A verbatim string literal consists of the @ character followed by a double-quote character, such as @hello. \n\n6.The Null literal - Represents the null-type.\n\n### Question: What is the main difference between sub-procedure and function?\n\nThe sub-procedure is a block of multiple visual basic statements within Sub and End Sub statements. It is used to perform certain tasks, such as changing properties of objects, receiving or processing data, and displaying an output. You can define a sub-procedure anywhere in a program, such as in modules, structures, and classes. \n\nWe can also provide arguments in a sub-procedure; however, it does not return a new value.The function is also a set of statements within the Function and End Function statements.It is similar to sub - procedure and performs the same task.The main difference between a function and a sub - procedure is that sub - procedures do not return a value while functions do.\n\nDetermine the output of the code snippet.\n\nint a = 29; \n\na--; \n\na -= ++a; \n\nConsole.WriteLine(The value of a is: { 0}, a); \n\no/p: -1\n\n### Question: Differentiate between Boxing and Unboxing.\n\nWhen a value type is converted to an object type, the process is known as boxing; whereas, when an object type is converted to a value type, the process is known as unboxing. \n\n\nBoxing and unboxing enable value types to be treated as objects. Boxing a value type packages it inside an instance of the Object reference type. This allows the value type to be stored on the garbage collected heap. Unboxing extracts the value type from the object. In this example, the integer variable iis  boxed and assigned to object obj. \n\nBoxing Example:\n\npublic void function1()\n\n{int i =111; object o = i;//implicit unboxing\n\nconsole.writeline(o); }\n\nUnboxing Example:\n\npublic void function1()\n\n{object o =111;\n\nint i = (int)o;//explicit unboxing\n\nconsole.writeline(i);   }\n\n# CSharp (C#) \n\n### Question: What is C#?\n\nC# is the best language for writing Microsoft .NET applications. C# provides the rapid application development found in Visual Basic with the power of C++. Its syntax is similar to C++ syntax and meets 100% of the requirements of OOPs like the following:\n\n• Abstraction\n\n• Encapsulation\n\n• Polymorphism\n\n• Inheritance\n\n### Question: What is an Object?\n\nAccording to MSDN, \"a class or struct definition is like a blueprint that specifies what the type can do. An object is basically a block of memory that has been allocated and configured according to the blueprint. A program may create many objects of the same class. Objects are also called instances, and they can be stored in either a named variable or in an array or collection. Client code is the code that uses these variables to call the methods and access the public properties of the object. In an object-oriented language such as C#, a typical program consists of multiple objects interacting dynamically\".\n\n### Question: What is the difference between a struct and a class in C#?\n\nClass and Struct both are the user defined data type but have some major difference:\n\nStruct\n\n• The struct is value type in C# and it inherits from System.Value Type.\n\n• Struct is usually used for smaller amounts of data.\n\n• Struct can’t be inherited to other type.\n\n• A structure can't be abstract.\n\n• No need to create object by new keyword.\n\n• Do not have permission to create any default constructor.\n\nClass\n\n• The class is reference type in C# and it inherits from the System.Object Type.\n\n• Classes are usually used for large amounts of data.\n\n• Classes can be inherited to other class.\n\n• A class can be abstract type.\n\n• We can’t use an object of a class with using new keyword.\n\n• We can create a default constructor.\n\n### Question: What is the difference between Interface and Abstract Class?\n### What is an Abstract Class?\n\nAn abstract class is a special kind of class that cannot be instantiated. So the question is why we need a class that cannot be instantiated? An abstract class is only to be sub-classed (inherited from). In other words, it only allows other classes to inherit from it but cannot be instantiated. The advantage is that it enforces certain hierarchies for all the subclasses. In simple words, it is a kind of contract that forces all the subclasses to carry on the same hierarchies or standards.\n\n### What is an Interface?\n\nAn interface contains only the signatures of methods, properties, events or indexers. A class or struct that implements the interface must implement the members of the interface that are specified in the interface definition. In the following example, class ImplementationClass must implement a method named SampleMethod that has no parameters and returns void.\n\nAn interface is not a class. It is an entity that is defined by the word Interface. An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body. As one of the similarities to Abstract class, it is a contract that is used to define hierarchies for all subclasses or it defines specific set of methods and their arguments. The main difference between them is that a class can implement more than one interface but can only inherit from one abstract class. Since C# doesn't support multiple inheritance, interfaces are used to implement multiple inheritance.\n\nWhen we create an interface, we are basically creating a set of methods without any implementation that must be overridden by the implemented classes. The advantage is that it provides a way for a class to be a part of two classes: one from inheritance hierarchy and one from the interface.\n\nWhen we create an abstract class, we are creating a base class that might have one or more completed methods but at least one or more methods are left uncompleted and declared abstract. If all the methods of an abstract class are uncompleted then it is same as an interface. The purpose of an abstract class is to provide a base class definition for how a set of derived classes will work and then allow the programmers to fill the implementation in the derived classes.\n\n  interface ISampleInterface\n    {        void SampleMethod();     }\n    class ImplementationClass : ISampleInterface\n    {        // Explicit interface member implementation: \n        void ISampleInterface.SampleMethod()\n        {            // Method implementation.\n        }\n        static void Main()\n        {            // Declare an interface instance.\n            ISampleInterface obj = new ImplementationClass();\n            // Call the member.\n            obj.SampleMethod();\n        }    }\n\n\n\nFeature\nInterface\nAbstract class\nMultiple inheritance\nA class may inherit several interfaces.\nA class may inherit only one abstract class.\nDefault implementation\nAn interface cannot provide any code, just the signature.\nAn abstract class can provide complete, default code and/or just the details that have to be overridden.\nAccess Modifiers\nAn interface cannot have access modifiers for the subs, functions, properties etc everything is assumed as public\nAn abstract class can contain access modifiers for the subs, functions, properties\nCore VS Peripheral\nInterfaces are used to define the peripheral abilities of a class. In other words both Human and Vehicle can inherit from a IMovable interface.\nAn abstract class defines the core identity of a class and there it is used for objects of the same type.\nHomogeneity\nIf various implementations only share method signatures then it is better to use Interfaces.\nIf various implementations are of the same kind and use common behaviour or status then abstract class is better to use.\nSpeed\nRequires more time to find the actual method in the corresponding classes.\nFast\nAdding functionality (Versioning)\nIf we add a new method to an Interface then we have to track down all the implementations of the interface and define implementation for the new method.\nIf we add a new method to an abstract class then we have the option of providing default implementation and therefore all the existing code might work properly.\nFields and Constants\nNo fields can be defined in interfaces\nAn abstract class can have fields and constraints defined\n\n\n\n### Question: What is enum in C#?\n    \n An enum is a value type with a set of related named constants often referred to as an enumerator list. The enum keyword is used to declare an enumeration. It is a primitive data type, which is user defined.\n    \n\nAn enum type can be an integer (float, int, byte, double etc.). But if you used beside int it has to be cast.\n    \n\nAn enum is used to create numeric constants in .NET framework. All the members of enum are of enum type. There must be a numeric value for each enum type.\n\nThe default underlying type of the enumeration element is int. By default, the first enumerator has the value 0, and the value of each successive enumerator is increased by 1.\n\nenum Dow {Sat, Sun, Mon, Tue, Wed, Thu, Fri};\n\nSome points about enum-\n\n• Enums are enumerated data type in c#.\n\n• Enums are not for end-user, they are meant for developers.\n\n• Enums are strongly typed constant. They are strongly typed, i.e. an enum of one type may not be implicitly assigned to an enum of \nanother type even though the underlying value of their members is the same.\n\n• Enumerations (enums) make your code much more readable and understandable.\n\n• Enum values are fixed. Enum can be displayed as a string and processed as an integer.\n\n• The default type is int, and the approved types are byte, sbyte, short, ushort, uint, long, and ulong.\n\n• Every enum type automatically derives from System.Enum and thus we can use System.Enum methods on enums.\n\n• Enums are value types and are created on the stack and not on the heap.\n\n### Question: What is the difference between “continue” and “break” statements in C#?\n\nUsing break statement, you can 'jump out of a loop' whereas by using continue statement, you can 'jump over one iteration' and then resume your loop execution.\n\nBreak Statement Example-\n\nusing System;\n\nusing System.Collections;\n\nusing System.Linq;\n\nusing System.Text;\n\nnamespace break_example \n\n{\n{\nClass brk_stmt \n{\n\npublic static void main(String[] args) {\n\nfor (int i = 0; i \u003c= 5; i++) {\n\nif (i == 4) {continue;  }\n\nConsole.ReadLine(“The number is” + i); \n\n}\n}\n}\n}\n\nOutput:\nThe number is 0;\nThe number is 1;\nThe number is 2;\nThe number is 3;\n\nContinue Statement Example\n\nusing System;\n\nusing System.Collections;\n\nusing System.Linq;\n\nusing System.Text;\n\nnamespace continue_example\n\n{\nClass cntnu_stmt\n\n{\npublic static void main(String[]\n\n{\nfor (int i = 0; i \u003c= 5; i++)\n\n{\n\nif (i == 4)\n\n{\n\ncontinue; \n\n}\n\nConsole.ReadLine(“The number is” +i); \n\n} \n\n}\n} \n}\n\nOutput:\n\nThe number is 1;\nThe number is 2;\nThe number is 3;\nThe number is 5;\n\n### Question: What is the difference between constant and readonly in c#?\n\nConstants perform the same tasks as read-only variables with some differences. The differences between constants and read-only are \n\nConstants: \n\n1.Constants are dealt with at compile-time. \n\n2.Constants supports value-type variables. \n\n3.Constants should be used when it is very unlikely that the value will ever change. \n\nRead-only: \n\n1.Read-only variables are evaluated at runtime. \n\n2.Read-only variables can hold reference type variables. \n\n3.Read-only variables should be used when run-time calculation is required.\n\nSee the example\n\nWe have a Test Class in which we have two variables one is readonly and another is constant.\n\n\nclass Test { \n\nreadonly int read = 10;const int cons = 10;\n\n\npublic Test() { read = 100;  cons = 100; }\n\n\npublic void Check() {  Console.WriteLine(\"Read only : {0}\", read);\n\n\nConsole.WriteLine(\"const : {0}\", cons);\n\n\n}\n}\n\nHere I was trying to change the value of both the variables in constructor but when I am trying to change the constant it gives an error to change their value in that block which have to call at run time.\n\n\n\n\n\nSo finally remove that line of code from class and call this Check() function like the following code snippet:\n\nclass Program {\n\nstatic void Main(string[] args) {\n\nTest obj = new Test();   obj.Check();   Console.ReadLine();\n\n}\n}\n\nclass Test {\n\nreadonly int read = 10;\n\nconst int cons = 10;\n\npublic Test() { read = 100;}\n\npublic void Check() {\n\nConsole.WriteLine(\"Read only : {0}\", read); \n\nConsole.WriteLine(\"const : {0}\", cons);\n\n}\n}\n\nOutput:\n\n\n\n\n### Question: What is the difference between ref and out keywords?\n\nIn C Sharp (C#) we can have three types of parameters in a function. The parameters can be in parameter (which is not returned back to the caller of the function), out parameter and ref parameter. We have lots of differences in both of them.\nBoth ref and out are treated differently at run time and they are treated the same at compiler\nproperties are not variables, therefore it cannot be passed as an out or ref parameter\n\nRef\n\nThe parameter or argument must be initialization first before it is passed to ref\n\nA called method is required to assign or initialize a value of a parameter (which is passed to an out)before returning to the calling method\n\nPassing a parameter value by ref is useful when the called method is also needed to modify the pass parameter\n\n\nA parameter value must be initialized within calling method before its use\n\nWhen we use ref data can be passed bidirectionally\n\n\nOut\n\nIt is compulsory to initialize a parameter or argument before it is passed to an out\n\nIt is not required to assign or initialize the value of a parameter(which is passed by ref ) before returning to the calling method \n\nDeclaring a parameter to an out method is when multiple values need to be returned for function or method\n\nIt is not compulsory to initialize a parameter value before using it in a calling method\n\nWhen we use out data is passed only in unidirectional way (from the called method caller )\n\n### Question: Can “this” be used within a static method?\n\nWe can't use this in static method because keyword 'this' returns a reference to the current instance of the class containing it. \n\nStatic methods (or any static member) do not belong to a particular instance. They exist without creating an instance of the class and call with the name of a class not by instance so we can’t use this keyword in the body of static Methods, but in case of Extension Methods we can use it the functions parameters. Let’s have a look on “this” keyword.\n\nThe \"this\" keyword is a special type of reference variable that is implicitly defined within each constructor and non-static method as a first parameter of the type class in which it is defined. For example, consider the following class written in C#.\n\nLet me explain you with a simple practical demonstration.\n\nusing System;\n\nusing System.Collections.Generic;\n\nusing System.Linq;\n\nusing System.Text;\n\nnamespace this_example\n{\n    class Program\n    {\n        public class Demo\n        {\n            int age;\n            string name;\n\n            public Demo(int age, string name)\n            {\n                age = age;\n                name = name;\n            }\n\n            public void Show()\n            {\n                Console.WriteLine(\"Your age is :\" + age.ToString());\n                Console.WriteLine(\"Your name is : \" + name);\n            }        }\n        static void Main(string[] args)\n        {\n            int _age;\n            string _name;\n\n            Console.WriteLine(\"Enter your age : \" );\n            _age=Int32.Parse(Console.ReadLine());\n\n            Console.WriteLine(\"Enter your name : \");\n            _name=Console.ReadLine();\n\n            Demo obj = new Demo(_age, _name);\n\n            obj.Show();\n            Console.ReadLine();\n         }    }}\n\nOutput of the above program will be:\n\n\n\nSee your not getting any value. Because in the program the local data members age, name have precedence over instance members. \n\nNote the program will give a warning not error (Assignment made to some variable; did you mean to assign something else?)\n\nWe have to use this keyword to refer to the instance members.\n\nNow I do a slight change in the program using this keyword.\n\nusing System;\n\nusing System.Collections.Generic;\n\nusing System.Linq;\n\nusing System.Text;\n\nnamespace this_example\n{\n    class Program\n    {\n        public class Demo\n        {\n            int age;\n            string name;\n\n            public Demo(int age, string name)\n            {                // Have made change here included this keyword\n                this.age = age;                this.name = name;             }\n            public void Show()\n            {                Console.WriteLine(\"Your age is :\" + age.ToString());\n                Console.WriteLine(\"Your name is : \" + name);   }        }\n\n        static void Main(string[] args)\n        {            int _age;   string _name;\n\n            Console.WriteLine(\"Enter your age : \" );\n            _age=Int32.Parse(Console.ReadLine());\n\n            Console.WriteLine(\"Enter your name : \");\n            _name=Console.ReadLine();\n\n            Demo obj = new Demo(_age, _name);\n\n            obj.Show();\n            Console.ReadLine();\n        }    } }\n\nSee the output. \n\n\n\nI think now this keyword would be clear to you. \n\nThe program is not complete implementation of this keyword but it tries to make you explain how it works and when to use.\n\n### Question: Define Property in C# .net?\n\nProperties are members that provide a flexible mechanism to read, write or compute the values of private fields, in other words by the property we can access private fields. In other words we can say that a property is a return type function/method with one parameter or without a parameter. These are always public data members. It uses methods to access and assign values to private fields called accessors.\n\n### Question: Now question is what are accessors?\n\nThe get and set portions or blocks of a property are called accessors. These are useful to restrict the accessibility of a property, the set accessor specifies that we can assign a value to a private field in a property and without the set accessor property it is like a read-only field. By the get accessor we can access the value of the private field, in other words it returns a single value. A Get accessor specifies that we can access the value of a field publicly.\n\nWe have the three types of properties\n\n•\tRead/Write.\n\n•\tReadOnly.\n\n•\tWriteOnly\n\n### Question: What is extension method in c# and how to use them?\n\nExtension methods enable you to add methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. An extension method is a special kind of static method, but they are called as if they were instance methods on the extended type.\n\n### Question : How to use extension methods?\n\nAn extension method is a static method of a static class, where the \"this\" modifier is applied to the first parameter. The type of the first parameter will be the type that is extended.\n\nExtension methods are only in scope when you explicitly import the namespace into your source code with a using directive.\nLike: suppose we have a class like below:\n\npublic class Class1 {\n\npublic string Display() {\n\nreturn (\"I m in Display\");}\n\npublic string Print() {\n\nreturn (\"I m in Print\");}}\n\nNow we need to extend the definition of this class so m going to create a static class to create an extinction method like:\n\npublic static class XX {\n\npublic static void NewMethod(this Class1 ob) {\n\nConsole.WriteLine(\"Hello I m extended method\");}}\n\nHere I just create a method that name is NewMethod with a parameter using this to define which type of data I need to be extend, now \nlet’s see how to use this function.\n\n\n\n\nCode will look like that:\n\nclass Program {\n\nstatic void Main(string[] args) {\n\nClass1 ob = new Class1();  ob.Display(); ob.Print(); ob.NewMethod();  Console.ReadKey();\n}\n}\n\n\nOutput will be:\n\n\n\n### Question: What is the difference between string and StringBuilder in c#?\n\nStringBuilder and string both use to store string value but both have many differences on the bases of instance creation and also for \nperformance:\n\nString: \n\nString is an immutable object. Immutable like when we create string object in code so we cannot modify or change that object in any \noperations like insert new value, replace or append any value with existing value in string object, when we have to do some operations \nto change string simply it will dispose the old value of string object and it will create new instance in memory for hold the new value \nin string object like:\n\nclass program{static void main(string[] args)\n\n{string val = “hello”;\n\n//create a new string instance instead of changing the old one\n\nval += “am”;\n\nval +=”nithin pandit”;\n\nconsole.writeline(val);\n\n}\n}\n\nNote:\n\n• It’s an immutable object that holds string value.\n\n• Performance wise string is slow because its’ create a new instance to override or change the previous value.\n\n• String belongs to System namespace.\n\nStringBuilder:\n\nSystem.Text.Stringbuilder is mutable object which also hold the string value, mutable means once we create a System.Text.Stringbuilder \nobject we can use this object for any operation like insert value in existing string with insert functions also replace or append \nwithout creating new instance of System.Text.Stringbuilder for every time so it’s use the previous object so it’s work fast as compare \nthan System.String. Let’s have an example to understand System.Text.Stringbuilder like:\n\nclass program\n\n{\nstatic void main(string[]args)\n{\n\nstringbuilder val =new stringbuilder(“”);\n\nval.append(“hello);\n\nval.append(“am nitin pandit:)”);\n\nconsole.writeline(val);}}\n\nNote:\n\n• StringBuilder is a mutable object.\n\n• Performance wise StringBuilder is very fast because it will use same instance of StringBuilder object to perform any operation like insert value in existing string.\n\n• StringBuilder belongs to System.Text.Stringbuilder namespace.\n\nString Example\n\nstring colors;\n\ncolors += \"red\";\n\ncolors += \"blue\";\n\ncolors += \"green\";\n\nIn the above code string color will alter 3 times, each time the code perform a string operation (+=). That mean 3 new string created in the memory. When you perform repeated operation to a string, the overhead associated with creating a new String object can be costly.\n\nStringBuilder Example\n\nStringBuilder sb = new StringBuilder(\"\");\n\nsb.Append(\"red\");\n\nsb.Append(\"blue\");\n\nsb.Append(\"green \");\n\nstring colors = sb.ToString();\n\nIn the above code the StringBuilder object will alter 3 times, each time the code attempt a StringBuilder operation without creating a new object. That means, using the StringBuilder class can boost performance when concatenating many strings together in a loop.\n\n### Question: What are delegates in C# and uses of delegates?\n\nA delegate object encapsulates a reference to a method. \n\nC# delegates are same as pointers to functions, in C or C++. A delegate Object is a reference type variable that use to holds the \nreference to a method. The reference can be changed at runtime which is hold by an object of delegate, a delegate object can hold many \nfunctions reference which is also known as Invocation List that refers functions in a sequence FIFO, we can new functions ref in this \nlist at run time by += operator and can remove by -= operator.\n\nDelegates are especially used for implementing events and the call-back methods. All delegates are implicitly derived from the \nSystem.Delegate class.\n\nLet’s see how to use Delegate with Example:\n\n\n\n\n\n\n\n\n\n\n\n### Question : What is sealed class in c#?\n\nSealed classes are used to restrict the inheritance feature of object oriented programming. Once a class is defined as a sealed class, the class cannot be inherited.\n\nIn C#, the sealed modifier is used to define a class as sealed. In Visual Basic .NET the Not Inheritable keyword serves the purpose of sealed. If a class is derived from a sealed class then the compiler throws an error.\n\nIf you have ever noticed, structs are sealed. You cannot derive a class from a struct.\n\nThe following class definition defines a sealed class in C#:\n\n// Sealed class\nsealed class SealedClass\n{\t}\n\n### Question : What are partial classes?\n\nA partial class is only use to splits the definition of a class in two or more classes in a same source code file or more than one source files. You can create a class definition in multiple files but it will be compiled as one class at run time and also when you’ll create an instance of this class so you can access all the methods from all source file with a same object.\n\nPartial Classes can be create in the same namespace it’s doesn’t allowed to create a partial class in different namespace. So use “partial” keyword with the entire class name which you want to bind together with the same name of class in same namespace, let’s have an example:\n\n### Question : What is IEnumerable\u003c\u003e in c#?\n\nIEnumerable is the parent interface for all non-generic collections in System.Collections namespace like ArrayList, HastTable etc. that can be enumerated. For the generic version of this interface as IEnumerable\u003cT\u003e which a parent interface of all generic collections class in System.Collections.Generic namespace like List\u003c\u003e and more.\nIn System.Collections.Generic.IEnumerable\u003cT\u003e have only a single method which is GetEnumerator() that returns an IEnumerator. IEnumerator provides the power to iterate through the collection by exposing a Current property and Move Next and Reset methods, if we doesn’t have this interface as a parent so we can’t use iteration by foreach loop or can’t use that class object in our LINQ query.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### Question : What is difference between late binding and early binding in c#?\n\nEarly Binding and Late Binding concepts belongs to polymorphism so let’s see first about polymorphism:\nPolymorphism is an ability to take more than one form of a function means with a same name we can write multiple functions code in a same class or any derived class.\n\nPolymorphism we have 2 different types to achieve that:\n    • Compile Time also known as Early Binding or Overloading.\n    • Run Time also known as Late Binding or Overriding.\n\nCompile Time Polymorphism or Early Binding: In Compile time polymorphism or Early  Binding we will use multiple methods with same name but different type of parameter or may be the number or parameter because of this we can perform different-different tasks with same method name in the same class which is also known as Method overloading.\n\nSee how we can do that by the following example:\n\n\n\n\n\n\n\nRunTime Polymorphism or Late Binding: Runtime polymorphism also known as late binding, in Run Time polymorphism or Late Binding we can do use same method names with same signatures means same type or same number of parameters but not in same class because compiler doesn’t allowed that at compile time so we can use in derived class that bind at run time when a child class or derived class object will instantiated that’s way we says that Late Binding.\n\nFor that we have to create my parent class functions as partial and in driver or child class as override functions with override keyword.\n\nLike as following example:\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n### Question : What are the differences between IEnumerable and IQueryable?\n\nBefore the differences learn what is IEnumerable and IQueryable.\n\nIEnumerable:\n\nIs the parent interface for all non-generic collections in System.Collections namespace like ArrayList, HastTable etc. that can be enumerated. For the generic version of this interface as IEnumerable\u003cT\u003e which a parent interface of all generic collections class in \n\tSystem.Collections.Generic namespace like List\u003c \u003e and more.\n\nIQueryable:\n\nAs per MSDN IQueryable interface is intended for implementation by query providers. It is only supposed to be implemented by providers that also implement IQueryable\u003cT\u003e. If the provider does not also implement IQueryable\u003cT\u003e, the standard query operators cannot be used on the provider's data source.\n\nThe IQueryable interface inherits the IEnumerable interface so that if it represents a query, the results of that query can be enumerated. Enumeration causes the expression tree associated with an IQueryable object to be executed. The definition of \"executing an expression tree\" is specific to a query provider. For example, it may involve translating the expression tree to an appropriate query language for the underlying data source. Queries that do not return enumerable results are executed when the Execute method is called.\n\nIenumerable\n\niqueryable\n\nienumerable belongs to system.collection namespace\n\ninquerable belongs to system.linq.namespace\n\nienumerable is the best way to write query on collections data type like list,array etc\n\niqueryable is the best way to write query data like remote database,service collections\n\nienumerable is the return type for linq to object and linq to xml queries\n\niqueryable is the return type of linq to sql queries\n\nienumerable doesnt support lazy loading so it's not a recommended approach for paging kind of scenarios\n\niquerable support lazy loading so we can also use in paging kind of scenarios\n\nextension methods are supports by ienumerable takes funtional objects for linq querys\n\niqueryable implements ienumerable so indirectly its also supports extensions methods\n\n### Question : What happens if the inherited interfaces have conflicting method names?\n\nIf we implement multiple interface in the same class with conflict method name so we don’t need to define all or in other words we can say if we have conflict methods in same class so we can’t implement their body independently in the same class coz of same name and same signature so we have to use interface name before method name to remove this method confiscation let’s see an \n\nexample:\n\ninterface testInterface1 {\n\nvoid Show(); }\n\ninterface testInterface2 {\n\nvoid Show(); }\n\nclass Abc: testInterface1,\n\ntestInterface2 {\n\nvoid testInterface1.Show() {\n\nConsole.WriteLine(\"For testInterface1 !!\");  }\n\nvoid testInterface2.Show() {\n\nConsole.WriteLine(\"For testInterface2 !!\"); }}\n\nNow see how to use those in a class:\n\nclass Program {\n\nstatic void Main(string[] args) {\n\ntestInterface1 obj1 = new Abc();\n\ntestInterface1 obj2 = new Abc();\n\nobj1.Show();\n\nobj2.Show();\n\nConsole.ReadLine();  } }\n\n\n\n\n\n### Question : What are the Arrays in C#.Net?\n\nArrays are powerful data structures for solving many programming problems. You saw during the creation of variables of many types that they have one thing in common; they hold information about a single item, for instance an integer, float and string type and so on. So what is the solution if you need to manipulate sets of items? One solution would be to create a variable for each item in the set but again this leads to a different problem. How many variables do you need?\n\nSo in this situation Arrays provide mechanisms that solves problem posed by these questions. An array is a collection of related items, either value or reference type. In C# arrays are immutable such that the number of dimensions and size of the array are fixed.\n\nArrays Overview-\n\nAn array contains zero or more items called elements. An array is an unordered sequence of elements. All the elements in an array are of the same type (unlike fields in a class that can be of different types). The elements of an array accessed using an integer index that always starts from zero. C# supports single-dimensional (vectors), multidimensional and jagged arrays.\n\nElements are identified by indexes relative to the beginning of the arrays. Indexes are also commonly called indices or subscripts and are placed inside the indexing operator ([]). Access to array elements is by their index value that ranges from 0 to (length-1).\n\nArray Properties\n\n• The length cannot be changed once created.\n\n• Elements are initialized to default values.\n\n• Arrays are reference types and are instances of System.Array.\n\n• Their number of dimensions or ranks can be determined by the Rank property.\n\n• An array length can be determined by the GetLength() method or Length property.\n\n### Question : What is the Constructor Chaining in C#?\n\nConstructor Chaining is a way to connect two or more classes in a relationship as Inheritance, in Constructor Chaining every child class constructor is mapped to parent class Constructor implicitly by base keyword so when you create an instance of child class to it’ll call parent’s class Constructor without it inheritance is not possible.\n\n### Question : What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?\n\nClone - Method creates a shallow copy of an array. A shallow copy of an Array copies only the elements of the Array, whether they are reference types or value types, but it does not copy the objects that the references refer to. The references in the new Array point to the same objects that the references in the original Array point to.\n\nCopyTo - The Copy static method of the Array class copies a section of an array to another array. The CopyTo method copies all the elements of an array to another one-dimension array. The code listed in Listing 9 copies contents of an integer array to an array of object types.\n\n### Question : Can Multiple Catch Blocks executed in c#?\n\nWe can use multiple Catches block with every try but when any Exceptions is throw by debugger so every catches match this exception type with their signature and catch the exception by any single catch block so that means we can use multiple catches blocks but only one can executed at once like:\n\nusing System;\n\nclass MyClient {\n\npublic static void Main() {\n\nint x = 0;\n\nint div = 0;\n\ntry {div = 100 / x;\n\nConsole.WriteLine(\"Not executed line\");\n\n} catch (DivideByZeroException de) {\n\nConsole.WriteLine(\"DivideByZeroException\");\n\n} catch (Exception ee) {\n\nConsole.WriteLine(\"Exception\");\n\n} finally {\n\nConsole.WriteLine(\"Finally Block\"); }\n\nConsole.WriteLine(\"Result is {0}\", div); } }\n\n### Question : Difference between Throw Exception and Throw Clause.\n\nThe basic difference is that the Throw exception overwrites the stack trace and this makes it hard to find the original code line number that has thrown the exception.\n\nThrow basically retains the stack information and adds to the stack information in the exception that it is thrown.\nLet us see what it means rather speaking so many words to better understand the differences. I am using a console application to easily test and see how the usage of the two differs in their functionality.\n\nusing System;\n\nusing System.Collections.Generic;\n\nusing System.Linq;\n\nusing System.Text;\n\nnamespace TestingThrowExceptions {\n\nclass Program {\n\npublic void ExceptionMethod() {\n\nthrow new Exception(\"Original Exception occurred in ExceptionMethod\"); \n\n}\n\nstatic void Main(string[] args) {\n\nProgram p = new Program();\n\ntry {p.ExceptionMethod();  }\n\ncatch (Exception ex) { \n\nthrow ex;  \n\n}\n}\n} \n}\n\nNow run the code by pressing the F5 key of the keyboard and see what happens. It returns an exception \n\n### Question : What is Indexer in C# .Net?\n\nIndexer allows classes to be used in more intuitive manner. C# introduces a new concept known as Indexers which are used for treating an object as an array. The indexers are usually known as smart arrays in C#. They are not essential part of object-oriented programming.\n\nAn indexer, also called an indexed property, is a class property that allows you to access a member variable of a class using the features of an array.\n\nDefining an indexer allows you to create classes that act like virtual arrays. Instances of that class can be accessed using the [] array access operator.\n\nCreating an Indexer:\n\n\u003c modifier \u003e\n\n\u003creturn type \u003e\n\t\nthis[argument list] {\n\nget {// your get block code}\n\nset {// your set block code}}\n\t\nIn the above code:\n\u003cmodifier\u003e - can be private, public, protected or internal.\n\n\u003creturn type\u003e - can be any valid C# types.\n\n### Question : What is multicast delegate in c#?\n\nA delegate that has multiple handlers assigned to it. Each assigned handler (method) is called.\nDelegate can invoke only one method reference has been encapsulated into the delegate.it is possible for certain delegate to hold and invoke multiple methods such delegate called multicast delegates.multicast delegates also know as combinable delegates, must satisfy the following conditions:\n\n• The return type of the delegate must be void. None of the parameters of the delegate type can be delegate type can be declared as output parameters using out keywords.\n\n• Multicast delegate instance that created by combining two delegates, the invocation list is formed by concatenating the invocation list of two operand of the addition operation. Delegates are invoked in the order they are added.\n\nImplement Multicast Delegates Example:\n\n\tusing System;\n\t\n\tusing System.Collections.Generic;\n\t\n\tusing System.Linq;\n\t\n\tusing System.Text;\n\t\n\tdelegate void MDelegate();\n\t\n\tclass DM {\n\t\n\tstatic public void Display() {\n\t\n\tConsole.WriteLine(\"Meerut\")   }\n\t\n\tstatic public void print() {\n\t\n\tConsole.WriteLine(\"Roorkee\"); } \t}\n\t\n\tclass MTest {\n\t\n\tpublic static void Main() {\n\t\n\tMDelegate m1 = new MDelegate(DM.Display);\n\t\n\tMDelegate m2 = new MDelegate(DM.print);\n\t\n\tMDelegate m3 = m1 + m2;\n\t\n\tMDelegate m4 = m2 + m1;\n\t\n\tMDelegate m5 = m3 - m2;\n\t\n\tm3(); \tm4(); \tm5();\n\t\n\t} \n\t\n\t}\n\n### Question : Difference between Equality Operator (==) and Equals() Method in C#.\n\nBoth the == Operator and the Equals() method are used to compare two value type data items or reference type data items. The Equality Operator (==) is the comparison operator and the Equals() method compares the contents of a string. The == Operator compares the reference identity while the Equals() method compares only contents. Let’s see with some examples.\nIn this example we assigned a string variable to another variable. A string is a reference type and in the following example, a string variable is assigned to another string variable so they are referring to the same identity in the heap and both have the same content so you get True output for both the == Operator and the Equals() method.\n\n\tusing System;\n\t\n\tnamespace ComparisionExample {\n\t\n\tclass Program {\n\t\n\tstatic void Main(string[] args) {\n\t\n\tstring name = \"Kansiris\";\n\t\n\tstring myName = name;\n\t\n\tConsole.WriteLine(\"== operator result is {0}\", name == myName);\n\t\n\tConsole.WriteLine(\"Equals method result is {0}\", name.Equals(myName));\n\t\n\tConsole.ReadKey(); \n\t\n\t} \n\t}\t\n\t}\n\n### Question : Difference between “is” and “as” operator in C#.\n\n\"is\" operator-\nIn the C# language, we use the \"is\" operator to check the object type. If the two objects are of the same type, it returns true and false if not.\nLet's understand the preceding from a small program. We defined the following two classes:\n\n\tclass Speaker {\n\tpublic string Name { \tget; \tset; \t} \t}\n\tclass Author {\n\tpublic string Name { \tget; \tset; \t} }\n\nNow, let's try to check the preceding types as:\n\n    • var speaker = new Speaker { Name=\"Gaurav Kumar Arora\"};\n    • We declared an object of Speaker as in the following:\n    • var isTrue = speaker is Speaker;\n    • In the preceding, we are just checking the matching type. Yes, our speaker is an object of Speaker type.\n    • Console.WriteLine(\"speaker is of Speaker type:{0}\", isTrue);\n    \nSo, the results as true.\n\nBut, here we get false:\n\n    • var author = new Author { Name = \"Gaurav Kumar Arora\" };\n    • var isTrue = speaker is Author;\n    • Console.WriteLine(\"speaker is of Author type:{0}\", isTrue);\n    \nBecause our speaker is not an object of Author type.\n\n\"as\" operator-\n\nThe \"as\" operator behaves similar to the \"is\" operator. The only difference is it returns the object if both are compatible to that \ntype else it returns null.\n\nLet's understand the preceding with a small snippet as in the following:\n\tpublic static string GetAuthorName(dynamic obj)\n\t{\tAuthor authorObj = obj as Author;\n\treturn (authorObj != null) ? authorObj.Name : string.Empty;  }\n\nWe have a method that accepts dynamic objects and returns the object name property if the object is of the Author type.\n\nHere, we declared two objects:\n\tvar speaker = new Speaker { Name=\"Gaurav Kumar Arora\"};\n\tvar author = new Author { Name = \"Gaurav Kumar Arora\" };\n\nThe following returns the \"Name\" property:\n\tvar authorName = GetAuthorName(author);\n\tConsole.WriteLine(\"Author name is:{0}\", authorName);\n\nIt returns an empty string:\n\tauthorName = GetAuthorName(speaker);\n\tConsole.WriteLine(\"Author name is:{0}\", authorName);\n\n### Question : How to use Nullable\u003c\u003e Types in .Net?\n\nA nullable Type is a data type is that contain the defined data type or the value of null. You should note here that here variable datatype has been given and then only it can be used.\n\nThis nullable type concept is not compatible with \"var\".\n\nI will explain this with syntax in next section.\n\nDeclaration:\n\nAny DataType can be declared nullable type with the help of operator \"?\".\n\nExample of the syntax is as Follows:\n\nint? i = null;\n\nAs discussed in previous section \"var\" is not compatible with this Nullable Type. So we will have Compile Time error if we are \ndeclaring something like: \n\nvar? i = null;\n\nThough following syntax is completely fine:\n\nvar i = 4;\n\n### Question : Different Ways of Method can be overloaded.\n\nMethod overloading is a way to achieve compile time Polymorphism where we can use a method with the same name but different signature, Method overloading is done at compile time and we have multiple way to do that but in all way method name should be same.\n\n◦ Number of parameter can be different.\n\n◦ Types of parameter can be different.\n\n◦ Order of parameters can be different.\n\nExample:\n\n\tusing System;\n\tusing System.Collections.Generic;\n\tusing System.Linq;\n\tusing System.Text;\n\tnamespace Hello_Word {\n\tclass overloding {\n\tpublic static void Main() {\n\tConsole.WriteLine(volume(10));\n\tConsole.WriteLine(volume(2.5F, 8));\n\tConsole.WriteLine(volume(100L, 75, 15));\n\tConsole.ReadLine();\n\t}\n\tstatic int volume(int x) {\treturn (x * x * x); \t}\n\tstatic double volume(float r, int h) {\treturn (3.14 * r * r * h); \t}\n\tstatic long volume(long l, int b, int h) {\treturn (l * b * h);\t\n\t}\n\t}\n\t}\nNote:\nIf we have a method that have two parameter object type and have a same name method with two integer parameter so when we call that method with int value so it’ll call that method have integer parameter instead of object type parameters method.\n\n### Question : What is an Object Pool in .Net?\n\nObject Pooling is something that tries to keep a pool of objects in memory to be re-used later and hence it will reduce the load of object creation to a great extent. This article will try to explain this in detail. The example is for an Employee object, but you can make it general by using Object base class.\n\n What does it mean?\n\nObject Pool is nothing but a container of objects that are ready for use. Whenever there is a request for a new object, the pool manager will take the request and it will be served by allocating an object from the pool.\n\nHow it works?\n\nWe are going to use Factory pattern for this purpose. We will have a factory method, which will take care about the creation of objects. Whenever there is a request for a new object, the factory method will look into the object pool (we use Queue object). If there is any object available within the allowed limit, it will return the object (value object), otherwise a new object will be created and give you back.\n\n### Question : What are generics in c#.net?\n\nGenerics allow you to delay the specification of the data type of programming elements in a class or a method, until it is actually used in the program. In other words, generics allow you to write a class or method that can work with any data type.\nYou write the specifications for the class or the method, with substitute parameters for data types. When the compiler encounters a constructor for the class or a function call for the method, it generates code to handle the specific data type.\n\n\n\n\n\n\n\n\nGeneric classes and methods combine reusability, type safety and efficiency in a way that their non-generic counterparts cannot. \n\nGenerics are most frequently used with collections and the methods that operate on them. Version 2.0 of the .NET Framework class library provides a new namespace, \n\nSystem.Collections.Generic, which contains several new generic-based collection classes. It is recommended that all applications that target the .NET Framework 2.0 and later use the new generic collection classes instead of the older non-generic counterparts such as ArrayList.\n\nFeatures of Generics:\n\nGenerics is a technique that enriches your programs in the following ways:\n\n• It helps you to maximize code reuse, type safety and performance.\n\n• You can create generic collection classes. The .NET Framework class library contains several new generic collection classes in the \n\nSystem.Collections.Generic namespace. You may use these generic collection classes instead of the collection classes in the System.Collections namespace.\n\n• You can create your own generic interfaces, classes, methods, events and delegates.\n\n• You may create generic classes constrained to enable access to methods on specific data types.\n\n• You may get information on the types used in a generic data type at run-time using reflection.\n\n### Question : Describe the accessibility modifiers in c#.Net\n\nAccess modifiers are keywords used to specify the declared accessibility of a member or a type.\n\nWhy to use access modifiers?\n\nAccess modifiers are an integral part of object-oriented programming. They support the concept of encapsulation, which promotes the idea of hiding functionality. Access modifiers allow you to define who does or doesn't have access to certain features. In C# there are 5 different types of Access Modifiers:\n\nModifier\n\nDescription\n\nPublic\n\nThere\tare no restrictions on accessing public members\t\n\nPrivate\n\t\t\nAccess \tis limited to within the class definition. This is the default access modifier type if none is formally specified\n\nProtected\n\nAccess \tis limited to within the class definition and any class that inherits from the class\n\nInternal\n\t\t\nAccess\tis limited exclusively to classes defined within the current project assembly\n\nProtected internal\n\nAccess\tis limited to current assembly\n\n### Question : What is Virtual Method in C#?\n\nA virtual method is a method that can be redefined in derived classes. A virtual method has an implementation in a base class as well as derived the class. It is used when a method's basic functionality is the same but sometimes more functionality is needed in the derived class. A virtual method is created in the base class that can be overridden in the derived class. We create a virtual method in the base class using the virtual keyword and that method is overridden in the derived class using the override keyword.\n\nWhen a method is declared as a virtual method in a base class then that method can be defined in a base class and it is optional for the derived class to override that method. The overriding method also provides more than one form for a method. Hence it is also an example for polymorphism.\n\nWhen a method is declared as a virtual method in a base class and that method has the same definition in a derived class then there is no need to override it in the derived class. But when a virtual method has a different definition in the base class and the derived class then there is a need to override it in the derived class.\n\nWhen a virtual method is invoked, the run-time type of the object is checked for an overriding member. The overriding member in the most derived class is called, which might be the original member, if no derived class has overridden the member.\n\nVirtual Method:\n\n1.\tBy default, methods are non-virtual. We can't override a non-virtual method.\n\n2.\tWe can't use the virtual modifier with the static, abstract, private or override modifiers.\n\n\n### Question : What is the Difference between Array and ArrayList in C#.Net?\n\nArray\n\nArrayList\t\n\nArray uses the vector array to store the elements\n\nArrayList uses the linked list to store the elements\n\nSize of the array must be defined until redeem used(vb) \n\nNo need to specify the storage size\n\nArray is specific data type storage\n\nArrayList can be stored everything as object\t\n\nNo need to do the typecasting\n\n\nEvery time type casting has to do\n\nIt will not lead to runtime exception\n\nIt leads to the runtime error exception\n\nElement cannot be inserted or deleted in between\n\nElements  can be inserted and deleted\t\n\nThere  is no build in members to do ascending or descending \n\nArraylist has many methods to do operation like sort insert, remove, binarysearch, etc\n\n\n\n\n### Question : What you understand by Value types and Reference types in C#.Net?\n\nIn C# data types can be of two types: Value Types and Reference Types. Value type variables contain their object (or data) directly. If \nwe copy one value type variable to another then we are actually making a copy of the object for the second variable. Both of them will \nindependently operate on their values, Value Type member will locate into Stack and reference member will locate in Heap always.\nLet consider each case briefly:\n\n• Pure Value Type: Here I used a structure as a value type. It has an integer member. I created two instances of this structure. Afterwards I assigned second instance to the first one. Then I changed the state of second instance, but it hasn't effect the first one, as whole items are value type and assignments on those types will copy only values not references i.e. in a Value Type assignment, all instances have its own local copy of members.\n\n• Pure Reference Type: I created a class and added a \"DataTable\" as a Reference Type member for this class. Then I performed the assignments just like below. But the difference is that on changing the state of second instance, the state of first instance will automatically alter. So in a Reference Type assignment both Value and Reference will be assigned i.e. all instances will point to the single object.\n\n• Value Type with Reference Type: This case and the last case to come are more interesting. I used a structure in this particular scenario also. But this time it includes a Reference Type (A Custom Class Object) Member besides a Value Type (An Integer) Member. When you performing the assignments, it seems like a swallow copy, as Value Type member of first instance won't effected, but the Reference Type member will alter according to the second instance. So in this particular scenario, assignment of Reference Type member produced a reference to a single object and assignment of Value Type member produced a local copy of that member.\n\n• Reference Type With Value Type : Contrary to the above case, in this scenario, both Reference \u0026 Value Types will be affected. I.e. a Value Type member in a Reference Type will be shared among its instances.\n\n### Question : What is Serialization?\n\nSerialization means saving the state of your object to secondary memory, such as a file. Suppose you have a business layer where you have many classes to perform your business data. Now suppose you want to test whether your business classes give the correct data out without verifying the result from the UI or from a database. Because it will take some time to process.\n\nHere comes Serialization. You will serialize all your necessary business classes and save them into a text or XML file, on your hard disk. So you can easily test your desired result by comparing your serialized saved data with, your desired output data. You can say it is a little bit of autonomic unit testing performed by the developer.\n\nThere are three types of serialization:\n\n• Binary serialization (Save your object data into binary format).\n\n• Soap Serialization (Save your object data into binary format; mainly used in network related communication).\n\n• Xml Serialization (Save your object data into an XML file).\n\n\n### Question : What is the use of using statement in C#?\n\nThe .Net Framework provides resource management for managed objects through the garbage collector - You do not have to explicitly allocate and release memory for managed objects. Clean-up operations for any unmanaged resources should perform in the destructor in C#. To allow the programmer to explicitly perform these clean-up activities, objects can provide a Dispose method that can be invoked when the object is no longer needed. The using statement in C# defines a boundary for the object outside of which, the object is automatically destroyed. The using statement is excited when the end of the \"using\" statement block or the execution exits the \"using\" statement block indirectly, for example - an exception is thrown. The \"using\" statement allows you to specify multiple resources in a single statement. The object could also be created outside the \"using\" statement. The objects specified within the using block must implement the IDisposable interface. The framework invokes the Dispose method of objects specified within the \"using\" statement when the block is exited.\n\n### Question : What is jagged array in C#.Net?\n\nA jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an \"array of arrays.\" A special type of array is introduced in C#. A Jagged Array is an array of an array in which the length of each array index can differ.\n\nExample:\n\nint[][] jagArray = new int[5][];\n\nIn the above declaration the rows are fixed in size. But columns are not specified as they can vary.\n\nDeclaring and initializing jagged array:\n\tint[][] jaggedArray = new int[5][];\n\tjaggedArray[0] = new int[3];\n\tjaggedArray[1] = new int[5];\n\tjaggedArray[2] = new int[2];\n\tjaggedArray[3] = new int[8];\n\tjaggedArray[4] = new int[10];\n\tjaggedArray[0] = new int[] { 3, 5, 7, };\n\tjaggedArray[1] = new int[] { 1, 0, 2, 4, 6 };\n\tjaggedArray[2] = new int[] { 1, 6 };\n\tjaggedArray[3] = new int[] { 1, 0, 2, 4, 6, 45, 67, 78 };\n\tjaggedArray[4] = new int[] { 1, 0, 2, 4, 6, 34, 54, 67, 87, 78 };\n\n### Question : What is Multithreading with .NET?\n\nThe real usage of a thread is not about a single sequential thread, but rather using multiple threads in a single program. Multiple threads running at the same time and performing various tasks is referred as Multithreading. A thread is considered to be a lightweight process because it runs within the context of a program and takes advantage of resources allocated for that program.\n\n\n\n\n\n\n\n\nA single-threaded process contains only one thread while a multithreaded process contains more than one thread for execution.\n\n \n\n\n\n\n\nSystem.Threading Namespace:\n\nLike many other features, in .NET, System.Threading is the namespace that provides various types to help in construction of multithreaded applications.\n\nType\n\nDescription\n\nThread\n\nIt represents a thread that executes within the CLR. Using this we can produce additional threads in an application domain\t\n\nMutex\t\n\nIt is used for synchronization between application domains\n\nMonitor\t\n\nIt implements synchronization of objects using locks and wait\n\nSmaphore\n\nIt allows limiting the number of threads that can access a resource concurrently\t\t\n\nInterlock\n\nIt provides atomic operations for variables that are shared by multiple threads\t\n\nThreadpool\n\nIt allows you to interact with the CLR maintained thread pool\n\nThread\n\nThis represents the priority levels such as high,low and normal\n\n\n### Question : Explain Anonymous type in C#?\n\nAnonymous types allow us to create new type without defining them. This is way to defining read only properties into a single object without having to define type explicitly. Here Type is generating by the compiler and it is accessible only for the current block of code. The type of properties is also inferred by the compiler.\n\nWe can create anonymous types by using “new” keyword together with the object initializer.\n\nExample:\n\tvar anonymousData = new\n\t{\tForeName = \"Jignesh\",\n\tSurName = \"Trivedi\"\t};\n\tConsole.WriteLine(\"First Name : \" + anonymousData.ForeName);\n\nAnonymous Types with LINQ Example:\nAnonymous types are also used with the \"Select\" clause of LINQ query expression to return subset of properties.\n\nExample:\nIf Any object collection having properties called FirstName , LastName, DOB etc. and you want only FirstName and LastName after the Querying the data then.\n\tclass MyData {\n\tpublic string FirstName {get;\tset;}\n\tpublic string LastName {get;.\tset;}\n\tpublic DateTime DOB {get;\tset;}\n\tpublic string MiddleName {get; set;\t}\t}\n\tstatic void Main(string[] args) {\n\t// Create Dummy Data to fill Collection.\n\tList \u003c MyData \u003e data = new List \u003c MyData \u003e ();\n\tdata.Add(new MyData {FirstName = \"Jignesh\", LastName = \"Trivedi\", MiddleName = \"G\", DOB = new DateTime(1990, 12, 30)});\n\tdata.Add(new MyData {FirstName = \"Tejas\", LastName = \"Trivedi\", MiddleName = \"G\", DOB = new DateTime(1995, 11, 6) 64});\n\tdata.Add(new MyData {FirstName = \"Rakesh\", LastName = \"Trivedi\", MiddleName = \"G\", DOB = new Date Time(1993, 10, 8)\t});\n\tdata.Add(new MyData {FirstName = \"Amit\", LastName = \"Vyas\", MiddleName = \"P\", DOB = newDateTime (1983, 6, 15)});\n\tdata.Add(new MyData {FirstName = \"Yash\", LastName = \"Pandiya\", MiddleName = \"K\", DOB = newDateTime(1988, 7, 20)});\t}\n\tvar anonymousData = from pl in data\n\tselect new {\tpl.FirstName, pl.LastName\t};\n\tforeach(var m in anonymousData) {\n\tConsole.WriteLine(\"Name : \" + m.FirstName + \" \" + m.LastName);  }\t}\n\n### Question : Explain Hashtable in C#?\n\nA Hashtable is a collection that stores (Keys, Values) pairs. Here, the Keys are used to find the storage location and are immutable and cannot have duplicate entries in the Hashtable. The .Net Framework has provided a Hash Table class that contains all the functionality required to implement a hash table without any additional development. The hash table is a general-purpose dictionary collection. Each item within the collection is a DictionaryEntry object with two properties: a key object and a value object. These are known as Key/Value. When items are added to a hash table, a hashcode is generated automatically. This code is hidden from the developer. All access to the table's values is achieved using the key object for identification. \nAs the items in the collection are sorted according to the hidden hash code, the items should be considered to be randomly ordered.\n\nThe Hashtable Collection: The Base Class libraries offers a Hashtable Class that is defined in the System.Collections namespace, so you don't have to code your own hash tables. It processes each key of the hash that you add every time and then uses the hash code to look up the element very quickly. The capacity of a hash table is the number of elements the hash table can hold. As elements are added to a hash table, the capacity is automatically increased as required through reallocation. It is an older .Net Framework type.\n\nDeclaring  a  Hashtable:  The  Hashtable  class  is  generally  found  in  the  namespace  called System.Collections. So to execute any of the examples, we have to add using System.Collections; to the source code. The declaration for the Hashtable is:\nHashtable HT = new Hashtable ();\n\n### Question : What is LINQ in C#?\n\nLINQ stands for Language Integrated Query. LINQ is a data querying methodology which provides querying capabilities to .NET languages with syntax similar to a SQL query\n\nLINQ has a great power of querying on any source of data. The data source could be collections of objects, database or XML files. We can easily retrieve data from any object that implements the IEnumerable\u003cT\u003e interface.\n\nAdvantages of LINQ:\n\n• LINQ offers an object-based, language-integrated way to query over data no matter where that data came from. So through LINQ we can query database, XML as well as collections.\n\n• Compile time syntax checking.\n\n• It allows you to query collections like arrays, enumerable classes etc. in the native   language of your application, and like VB or C# in much the same way as you would 66 query a database using SQL.\n\n\n\n\n\n\n\n\n\n\n\n### Question : What is File Handling in C#.Net?\n\nThe System.IO namespace provides four classes that allow you to manipulate individual files, as well as interact with a machine directory structure. The Directory and File directly extends System.Object and supports the creation, copying, moving and deletion of files using various static methods. They only contain static methods and are never instantiated. The FileInfo and DirecotryInfo types are derived from the abstract class FileSystemInfo type and they are typically, employed for obtaining the full details of a file or directory because their members tend to return strongly typed objects. They implement roughly the same public methods as a Directory and a File but they are stateful and the members of these classes are not static.\n\n### Question : What is Reflection in C#.Net?\n\nReflection typically is the process of runtime type discovery to inspect metadata, CIL code, late binding and self-generating code. At run time by using reflection, we can access the same \"type\" information as displayed by the ildasm utility at design time. The reflection is analogous to reverse engineering in which we can break an existing *.exe or *.dll assembly to explore defined significant contents information, including methods, fields, events and properties.\n\nYou can dynamically discover the set of interfaces supported by a given type using the System.Reflection namespace. This namespace contains numerous related types as follows:\n\nTypes\n\nDescription\n\nAssembly\n\nthis static class allows you to load,investigate and manipulate an assembly\n\nAssemblyname\n\nallows to exploration of adundant details behind an assembly\n\nEventinfo\n\ninformation about a given event\n\nPropertyinfo\n\nhold information of a specified property\n\nMethodinfo\n\ncontains information about a specified method\n\n\nReflection typically is used to dump out the loaded assemblies list, their reference to inspect methods, properties etcetera. \nReflection is also used in the external disassembling tools such Reflector, Fxcop and NUnit because .NET tools don't need to parse the source code similar to C++.\n\nMetadata Investigation:\n\nThe following program depicts the process of reflection by creating a console based application. This program will display the details of the fields, methods, properties and interfaces for any type within the mscorlib.dll assembly. Before proceeding, it is mandatory to import \"System.Reflection\".\n\nHere, we are defining a number of static methods in the program class to enumerate fields, methods and interfaces in the specified type. The static method takes a single \"System.Type\" parameter and returns void.\n\tstatic void FieldInvestigation(Type t) {\n\tConsole.WriteLine(\"*********Fields*********\");\n\tFieldInfo[] fld = t.GetFields();\n\tforeach(FieldInfo f in fld) {\tConsole.WriteLine(\"--\u003e{0}\", f.Name);\t}\t}\n\tstatic void MethodInvestigation(Type t) {\n\tConsole.WriteLine(\"*********Methods*********\");\n\tMethodInfo[] mth = t.GetMethods();\n\tforeach(MethodInfo m in mth) {\tConsole.WriteLine(\"--\u003e{0}\", m.Name); }\t}\n\n### Question : What is Expression Trees In C#?\n\nExpression and Expression\u003c\u003e are basically classes that can represent the CSharp code as Data. Unlike Func\u003c\u003e or Action\u003c\u003e Expressions are non-compiled Data about the code. Most of LINQ Providers has been built using Expressions.\nWalkthrough of a sample expression: Expression can be parsed, analyzed in the program.\nLet’s create a simple Expression:\n// A simple delegated operation which perform string join.\nFunc\u003cstring, string, string\u003e StringJoin = (str1, str2) =\u003e string.Concat(str1, str2);\nNow I want to parse it analyze it or may be doing some more but for that I need to treat this code as Data. Now let’s write an expression for the above lambda expression:\nExpression\u003cFunc\u003cstring, string, string\u003e\u003e StringJoinExpr = (str1, str2) =\u003e string.Concat(str1, str 2);\nThe Expression Tree can be visualized as with its major properties:\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nLet’s analyze our Expression according to above figure, and see what values are populated to understand the break of Expression statement:\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### Question : Differences between Object, Var and Dynamic type?\n\nObject\n    • Object was introduced with C# 1.0\t\n    • It can store any kind of value, because object is the base class of all type in .NET framework.\n    • Compiler has little information about the type.\n    • Object type can be passed as method argument and method also can return object type.\n    • Need to cast object variable to original type to use it and performing desired operations.\n    • Cause the problem at run time if the stored value is not getting converted to underlying data type.\n    • Useful when we don’t have more information about the data type.\n\nVar\n    • Var was introduced with C# 3.0\t\n    • It can store any type of value but It is mandatory to initialize var types at the time of declaration.\n    • It is type safe i.e. Compiler has all information about the stored value, so that it doesn't cause any issue at run-time.\n    • Var type cannot be passed as method argument and method cannot return object type. Var type work in the scope where it defined.\n    • No need to cast because compiler has all information to perform operations.\n    • Doesn't cause problem because compiler has all information about stored value.\n    • Useful when we don’t know actual type i.e. type is anonymous.\n\nDynamic\n    • Dynamic was introduced with C# 4.0\n    • It can store any type of the variable, similar to old VB language variable.\n    • It is not type safe i.e. Compiler doesn't have any information about the type of variable.\n    • Dynamic type can be passed as method argument and method also can return dynamic type.\n    • Casting is not required but you need to know the properties and methods related to stored type.\n    • Cause problem if the wrong properties or methods are accessed because all the information about stored value is get resolve only at run time.\n    • Useful when we need to code using reflection or dynamic languages or with the COM objects, because you need to write less code.\n\n### Question : What are OOPS Concepts?\n\nClass:  It is a collection of objects.\n\nObject: It is a real time entity.\n\nAn object can be considered a \"thing\" that can perform a set of related activities. The set of activities that the object performs defines the object's behavior. For example, the hand can grip something or aStudent (object) can give the name or address. In pure OOP terms an object is an instance of a class\n\nThe above template describe about object Student\n\nClass is composed of three things name, attributes, and operations\n\npublic class student\n{  }\n\nstudent objstudent=new student ();\n\nAccording to the above sample we can say that Student object, named objstudent, has created out of the student class.\n\nIn real world you will often find many individual objects all of the same kind. As an example, there may be thousands of other bicycles \nin existence, all of the same make and model. Each bicycle has built from the same blueprint. In object-oriented terms, we say that the bicycle is an instance of the class of objects known as bicycles. In the software world, though you may not have realized it, you have already used classes. For example, the Textbox control, you always used, is made out of the Textbox class, which defines its appearance and capabilities. Each time you drag a Textbox control, you are actually creating a new instance of the Textbox class.\n\nEncapsulation:\nEncapsulation is a process of binding the data members and member functions into a single unit.\nExample for encapsulation is class. A class can contain data structures and methods.\nConsider the following class\npublic class Aperture\n{public Aperture ()\n{  }\n\nprotected double height;\nprotected double width;\nprotected double thickness;\npublic double get volume()\n{Double volume=height * width * thickness;\nif (volume\u003c0)\nreturn 0;\nreturn volume;\n}}\n\nIn this example we encapsulate some data such as height, width, thickness and method Get Volume. Other methods or objects can interact with this object through methods that have public access modifier\n\nAbstraction:\n\nAbstraction is a process of hiding the implementation details and displaying the essential features.\nExample1: A Laptop consists of many things such as processor, motherboard, RAM, keyboard, LCD screen, wireless antenna, web camera, usb ports, battery, speakers etc. To use it, you don't need to know how internally LCD screens, keyboard, web camera, battery, wireless antenna, speaker’s works.  You just need to know how to operate the laptop by switching it on. Think about if you would have to call to the engineer who knows all internal details of the laptop before operating it. This would have highly expensive as well as not easy to use everywhere by everyone.\n\nSo here the Laptop is an object that is designed to hide its complexity.\n\nHow to abstract: - By using Access Specifiers\n.Net has five access Specifiers\nPublic --       Accessible outside the class through object reference.\nPrivate --     Accessible inside the class only through member functions.\nProtected -- Just like private but Accessible in derived classes also through member functions.\nInternal --    Visible inside the assembly. Accessible through objects.\nProtected Internal -- Visible inside the assembly through objects and in derived classes outside the assembly through member functions.\nLet’s try to understand by a practical example:-\npublic class Class1\n    {   int  i;                                         //No Access specifier means private\n        public  int j;                                        // Public\n        protected int k;                             //Protected data\n        internal int m;                        // Internal means visible inside assembly\n        protected internal int n;            //inside assembly as well as to derived classes outside assembly\n        static int x;                                 // This is also private\n        public static int y;                       //Static means shared across objects\n        [DllImport(\"MyDll.dll\")]\n        public static extern int MyFoo();       //extern means declared in this assembly defined in some other assembly\n        public void myFoo2()\n        {            //Within a class if you create an object of same class then you can access all data members through object reference even private data too\n            Class1 obj = new Class1();\n            obj.i =10;   //Error can’t access private data through object.But here it is accessible.:)\n            obj.j =10;            obj.k=10;            obj.m=10;            obj.n=10;\n       //     obj.s =10;  //Errror Static data can be accessed by class names only\n            Class1.x = 10;\n         //   obj.y = 10; //Errror Static data can be accessed by class names only\n            Class1.y = 10;        }    }\n\nNow lets try to copy the same code inside Main method and try to compile\n[STAThread]\n        static void Main()\n        {    //Access specifiers comes into picture only when you create object of class outside the class\n            Class1 obj = new Class1();\n       //     obj.i =10; //Error can’t access private data through object.\n            obj.j =10;\n      //      obj.k=10;     //Error can’t access protected data through object.\n            obj.m=10;\n            obj.n=10;\n       //     obj.s =10;  //Errror Static data can be accessed by class names only\n            Class1.x = 10;  //Error can’t access private data outside class\n         //   obj.y = 10; //Errror Static data can be accessed by class names only\n            Class1.y = 10;\n        }\n\nWhat if Main is inside another assembly\n\n[STAThread]\n        static void Main()\n        {\n           //Access specifiers comes into picture only when you create object of class outside the class\n            Class1 obj = new Class1();\n       //     obj.i =10; //Error can’t access private data through object.\n            obj.j =10;\n      //      obj.k=10;     //Error can’t access protected data through object.\n     //     obj.m=10; // Error can’t access internal data outside assembly\n    //      obj.n=10; // Error can’t access internal data outside assembly\n       //     obj.s =10;  //Errror Static data can be accessed by class names only\n            Class1.x = 10;  //Error can’t access private data outside class\n         //   obj.y = 10; //Errror Static data can be accessed by class names only\n            Class1.y = 10;\n        }\n\nIn object-oriented software, complexity is managed by using abstraction.\n\nAbstraction is a process that involves identifying the critical behavior of an object and eliminating irrelevant and complex details.\n\nInheritance:\n\nInheritance is a process of deriving the new class from already existing class\nC# is a complete object oriented programming language. Inheritance is one of the primary concepts of object-oriented programming. It allows you to reuse existing code. Through effective use of inheritance, you can save lot of time in your programming and also reduce errors, which in turn will increase the quality of work and productivity. A simple example to understand inheritance in C#.\n\nUsing System;\nPublic class BaseClass\n{    Public BaseClass ()\n    {        Console.WriteLine (\"Base Class Constructor executed\");    }\n    Public void Write ()\n    {        Console.WriteLine (\"Write method in Base Class executed\");    }\n}                       \nPublic class ChildClass: BaseClass\n{                      Public ChildClass ()\n    {        Console.WriteLine(\"Child Class Constructor executed\");    }\n   \n    Public static void Main ()\n    {        ChildClass CC = new ChildClass ();\n        CC.Write ();\n    }}\n\nIn the Main () method in ChildClass we create an instance of childclass. Then we call the write () method. If you observe the ChildClass does not have a write() method in it. This write () method has been inherited from the parent BaseClass.\nThe output of the above program is \n\nOutput:\n  Base Class Constructor executed\n  Child Class Constructor executed\n  Write method in Base Class executed\n\nThis output proves that when we create an instance of a child class, the base class constructor will automatically be called before the child class constructor. So in general Base classes are automatically instantiated before derived classes.\n\nIn C# the syntax for specifying BaseClass and ChildClass relationship is shown below. The base class is specified by adding a colon, \":\", after the derived class identifier and then specifying the base class name.\n\nSyntax:  class ChildClassName: BaseClass\n              {                   //Body              }\n\nC# supports single class inheritance only. What this means is, your class can inherit from only one base class at a time. In the code snippet below, class C is trying to inherit from Class A and B at the same time. This is not allowed in C#. This will lead to a compile time \n\nerror: Class 'C' cannot have multiple base classes: 'A' and 'B'.\n\npublic class A\n{        }\npublic class B\n{             }\npublic class C : A, B\n{                   }\n\nIn C# Multi-Level inheritance is possible. Code snippet below demonstrates mlti-level inheritance. Class B is derived from Class A. Class C is derived from Class B. So class C, will have access to all members present in both Class A and Class B. As a result of multi-level inheritance Class has access to A_Method(),B_Method() and C_Method(). \n\nNote: Classes can inherit from multiple interfaces at the same time. \n\n### Question : How can you implement multiple inheritance in C#? \n\nUsing Interfaces.\nUsing System;\nPublic class A\n{    Public void A_Method ()\n    {        Console.WriteLine (\"Class A Method Called\");    }}\nPublic class B: A\n{    Public void B_Method ()\n    {        Console.WriteLine (\"Class A Method Called\");    }}\nPublic class C: B\n{    Public void C_Method ()\n    {        Console.WriteLine (\"Class A Method Called\");    }              \n    Public static void Main ()\n    {        C C1 = new C ();\n        C1.A_Method ();        C1.B_Method ();        C1.C_Method ();\n    }}\nWhen you derive a class from a base class, the derived class will inherit all members of the base class except constructors. In the code snippet below class B will inherit both M1 and M2 from Class A, but you cannot access M2 because of the private access modifier. Class members declared with a private access modifier can be accessed only with in the class. \n\n\n### Question : Are private class members inherited to the derived class?\n\nYes, the private members are also inherited in the derived class but we will not be able to access them. Trying to access a private base class member in the derived class will report a compile time error.\n\nUsing System;\nPublic class A\n{Public void M1 ()\n{    }\nPrivate void M2 ()\n{   }}\n\nPublic class B: A\n{Public static void Main ()\n{B B1 = new B ();\nB1.M1 ();\n//Error, Cannot access private member M2\n//B1.M2 ();\n}}\n\nMethod Hiding and Inheritance We will look at an example of how to hide a method in C#. The Parent class has a write () method which is available to the child class. In the child class I have created a new write () method. So, now if I create an instance of child class and call the write () method, the child class write () method will be called. The child class is hiding the base class write () method. \n\nThis is called method hiding. \n\nIf we want to call the parent class write () method, we would have to type cast the child object to Parent type and then call the write () method as shown in the code snippet below.\n\nUsing System;\nPublic class Parent\n{   Public void Write ()\n    {        Console.WriteLine (\"Parent Class write method\");    }}\n \n\nPublic class Child: Parent\n{    Public new void Write ()\n    {         Console.WriteLine (\"Child Class write method\");     }\n       Public static void Main ()\n    {         Child C1 = new Child ();\n        C1.Write ();        //Type caste C1 to be of type Parent and call Write () method\n        ((Parent) C1).Write ();\n    }}\n\nPolymorphism:\n\nWhen a message can be processed in different ways is called polymorphism. Polymorphism means many forms. Polymorphism is one of the fundamental concepts of OOP.\n\nPolymorphism provides following features: \n\n•\tIt allows you to invoke methods of derived class through base class reference during runtime.\n\n•\tIt has the ability for classes to provide different implementations of methods that are called through the same name. \n\nPolymorphism is of two types:\n\n1.\tCompile time polymorphism/Overloading\n\n2.\tRuntime polymorphism/Overriding\n\nCompile Time Polymorphism\n\nCompile time polymorphism is method and operators overloading. It is also called early binding.\n\nIn method overloading method performs the different task at the different input parameters.\n\n\nRuntime Time Polymorphism\n\nRuntime time polymorphism is done using inheritance and virtual functions. Method overriding is called runtime polymorphism. It is also \ncalled late binding.\n\nWhen overriding a method, you change the behavior of the method for the derived class.  Overloading a method simply involves having \nanother method with the same prototype.\n\nCaution: Don't confused method overloading with method overriding, they are different, unrelated concepts. But they sound similar.\n\nMethod overloading has nothing to do with inheritance or virtual methods.\n\nFollowing are examples of methods having different overloads:\n\nvoid area(int side);\n\nvoid area(int l, int b);\n\nvoid area(float radius);\n\nPractical example of Method Overloading (Compile Time Polymorphism)\n\nusing System;\n namespace method_overloading\n{    class Program\n    {        public class Print\n        {             public void display(string name)\n            {                Console.WriteLine (\"Your name is : \" + name);            }\n             public void display(int age, float marks)\n            {                Console.WriteLine (\"Your age is : \" + age);\n                Console.WriteLine (\"Your marks are :\" + marks);\n            }        }\n        static void Main(string[] args)\n        {             Print obj = new Print ();\n            obj.display (\"George\");\n            obj.display (34, 76.50f);\n            Console.ReadLine ();\n        }    }} \n\nNote: In the code if you observe display method is called two times. Display method will work according to the number of parameters and type of parameters.\n\n### Question : When and why to use method overloading\n\nUse method overloading in situation where you want a class to be able to do something, but there is more than one possibility for what information is supplied to the method that carries out the task.\n\nYou should consider overloading a method when you for some reason need a couple of methods that take different parameters, but conceptually do the same thing.  Method overloading showing many forms.\n\nusing System;\n namespace method_overloading_polymorphism\n{    Class Program\n    {        Public class Shape\n        {            Public void Area (float r)\n            {                float a = (float)3.14 * r;\n                // here we have used function overload with 1 parameter.\n                Console.WriteLine (\"Area of a circle: {0}\",a);\n            }\n             Public void Area(float l, float b)\n            {                float x = (float)l* b;\n                // here we have used function overload with 2 parameters.\n                Console.WriteLine (\"Area of a rectangle: {0}\",x);\n             }\n             public void Area(float a, float b, float c)\n            {                float s = (float)(a*b*c)/2;\n                // here we have used function overload with 3 parameters.\n                Console.WriteLine (\"Area of a circle: {0}\", s);\n            }        }\n        Static void Main (string[] args)\n        {            Shape ob = new Shape ();\n            ob.Area(2.0f);            ob.Area(20.0f,30.0f);\n            ob.Area(2.0f,3.0f,4.0f);\n            Console.ReadLine ();        }    } } \n \n Things to keep in mind while method overloading  If you use overload for method, there are couple of restrictions that the compiler imposes.  The rule is that overloads must be different in their signature, which means the name and the number and type of parameters.  There is no limit to how many overload of a method you can have. You simply declare them in a class, just as if they were different methods that happened to have the same name.\n\nMethod Overriding:\n\nWhereas Overriding means changing the functionality of a method without changing the signature. We can override a function in base class by creating a similar function in derived class. This is done by using virtual/overrides keywords. Base class method has to be marked with virtual keyword and we can override it in derived class using override keyword. Derived class method will completely overrides base class method i.e. when we refer base class object created by casting derived class object a method in derived class will be called.\n\nExample: \n// Base class\npublic class BaseClass\n{public virtual void Method1()\n{Console.Write(\"Base Class Method\");}}\n// Derived class\npublic class DerivedClass : BaseClass\n{public override void Method1()\n{Console.Write(\"Derived Class Method\"); }}\n// Using base and derived class\npublic class Sample\n{public void TestMethod()\n{// calling the overriden method\nDerivedClass objDC = new DerivedClass(); \nobjDC.Method1();\n // calling the baesd class method\nBaseClass objBC = (BaseClass)objDC; \nobjDC.Method1();}}\n\nOutput:\n\nDerived Class Method\nDerived Class Method\n\nConstructors and Destructors:\n\nClasses have complicated internal structures, including data and functions, object initialization and cleanup for classes is much more complicated than it is for simple data structures. Constructors and destructors are special member functions of classes that are used to construct and destroy class objects. Construction may involve memory allocation and initialization for objects.\n\nDestruction may involve cleanup and deallocation of memory for objects.\n    • Constructors and destructors do not have return types nor can they return values.\n    • References and pointers cannot be used on constructors and destructors because their addresses cannot be taken.\n    • Constructors cannot be declared with the keyword virtual.\n    • Constructors and destructors cannot be declared const, or volatile.\n    • Unions cannot contain class objects that have constructors or destructors.\n\nConstructors and destructors obey the same access rules as member functions. For example, if you declare a constructor with protected access, only derived classes and friends can use it to create class objects.\n\nThe compiler automatically calls constructors when defining class objects and calls destructors when class objects go out of scope. A constructor does not allocate memory for the class object it’s this pointer refers to, but may allocate storage for more objects than its class object refers to. If memory allocation is required for objects, constructors can explicitly call the new operator. During cleanup, a destructor may release objects allocated by the corresponding constructor. To release objects, use the delete operator.\n\nExample of Constructor\n\nclass C\n{       private int x;    \n       private int y;\n       public C (int i, int j)\n       {                 x = i;                 y = j;       }\n       public void display ()     \n       {               Console.WriteLine(x + \"i+\" + y);       }}\n\nExample of Destructor\nclass D\n{        public D ()\n        {            // constructor        }         \n        ~D ()\n        {           // Destructor        }  }\n\n### Question : Does C# support multiple-inheritance? \n\nNo. But you can use Interfaces.\n\n### Question : Where is a protected class-level variable available? \n \n It is available to any sub-class derived from base c\n las\n\n### Question : Are private class-level variables inherited? \n\nYes, but they are not accessible. \n\n### Question : Describe the accessibility modifier “protected internal”. \n\nIt is available to classes that are within the same assembly and derived from the specified base class. \n\n### Question : Which class is at the top of .NET class hierarchy? \n\nSystem.Object. \n\n### Question : What does the term immutable mean?\n\nThe data value may not be changed. \n\nNote: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory. \n\n### Question : Can you store multiple data types in System.Array?\n\nNo. \n\n### Question : What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?\n\nThe Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object.\n\n### Question : How can you sort the elements of the array in descending order?\n\nBy calling Sort() and then Reverse() methods. \n\n### Question : What’s the .NET collection class that allows an element to be accessed using a unique key?\n\nHashTable. \n\n### Question : What class is underneath the SortedList class?\n\nA sorted HashTable. \n\n### Question : Will the finally block get executed if an exception has not occurred?\n\nYes. \n\n### Question : What’s the C# syntax to catch any possible exception?\n\nA catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}. \n\n### Question : Can multiple catch blocks be executed for a single try statement?\n\nNo. Once the proper catch block processed, control is transferred to the finally block .\n\n### Question : Explain the three services model commonly know as a three-tier application?\n\nPresentation (UI), Business (logic and underlying code) and Data (from storage or other sources). \n\n### Question : What is the syntax to inherit from a class in C#? \n\nPlace a colon and then the name of the base class.\n\nExample: class MyNewClass : MyBaseClass.\n\n### Question : Can you prevent your class from being inherited by another class? \n\nYes. The keyword “sealed” will prevent the class from being inherited. \n\n### Question : Can you allow a class to be inherited, but prevent the method from being over-ridden?\n\nYes. Just leave the class public and make the method sealed. \n\n### Question : When do you absolutely have to declare a class as abstract?\n\n1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden. \n\n2. When at least one of the methods in the class is abstract. \n\n\n### Question : Why can’t you specify the accessibility modifier for methods inside the interface?\n\nThey all must be public, and are therefore public by default. \n\n### Question : Can you inherit multiple interfaces?\n\nYes. .NET does support multiple interfaces. \n\n### Question :  What happens if you inherit multiple interfaces and they have conflicting method names?\n\nIt’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay. \n\n### Question : What’s the implicit name of the parameter that gets passed into the set method/property of a class? \n\nValue. The data type of the value parameter is defined by whatever data type the property is declared .\n\n### Question : Can you declare an override method to be static if the original method is not static? \n\nNo. The signature of the virtual method must remain the same. (Note: Only the keyword virtual is changed to keyword override) \n\n### Question : What are the different ways a method can be overloaded? \n\nDifferent parameter data types, different number of parameters, different order of parameters. \n\n### Question : If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?\n\nYes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.\n\n### Question :  What’s the implicit name of the parameter that gets passed into the class’ set method?\n\nValue, and it’s datatype depends on whatever variable we’re changing.\n\n### Question : How do you inherit from a class in C#? \n\nPlace a colon and then the name of the base class.\n\n### Question : Does C# support multiple inheritance?\n\nNo, use interfaces instead.\n\n### Question :  When you inherit a protected class-level variable, who is it available to?\n\nClasses in the same namespace.\n\n### Question :  Are private class-level variables inherited?\n\nYes, but they are not accessible, so looking at it you can honestly say that they are not inherited. \n\n### Question :  Describe the accessibility modifier protected internal.?\n\nIt’s available to derived classes and classes within the same assembly(and naturally from the base class it’s declared in).\n\n### Question : C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write? \n\nTwo. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there’s no implementation in it.\n\n### Question : What’s the top .NET class that everything is derived from? \n\nSystem.Object.\n\n### Question : What does the keyword virtual mean in the method definition?\n\nThe method can be over-ridden.\n\n### Question : Can you declare the override method static while the original method is non-static?\n\nNo, you can’t, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.\n\n### Question : Can you override private virtual methods?\n\nNo, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.\n\n### Question : When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)?\n\nWhen at least one of the methods in the class is abstract. When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden.\n\n### Question : Why can’t you specify the accessibility modifier for methods inside the interface? \n\nThey all must be public. Therefore, to prevent you from getting the false impression that you have any freedom of choice, you are not allowed to specify any accessibility, it’s public by default.\n\n### Question : And if they have conflicting method names? \n\nIt’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay.\n\n### Question : If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor? \n\nYes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.\n\n### Question : Is it namespace class or class namespace? \n\nThe .NET class library is organized into namespaces. Each namespace contains a functionally related group of classes so natural namespace comes first.\n\n### Question : What is the difference between ToString() and Convert.ToString()?\n\nToString() doesnot handle null values butConvert.ToString() will handle null values\n\n### Question : What is the Difference between int.Parse() and Convert.ToInt32()?\n\nint.Parse()  will convert only string to int Convert.ToInt32() is used to convert any \ndatatype to int type\n\n### Question : What is checked block and unchecked block?\n\nchecked block is used to enable overflow checking for arthimetic and conversion \nfunctions\n\nEx: byte b=254;\n b++;\n Console.WriteLine(b);\n O/p is: 255\n\nEx: byte b=254;\n b++;  b++;\n Console.WriteLine(b);\n\nO/p is 0 because the range of byte is 0-255 so if the range is exceeded then the b value will round to 0 but this type of programming is not safe type it is unsafe\n\nif we want to display error message instead of 0 then we have to go for checked block\n\nEx: Checked\n\n{  byte b=254;\n b++;   b++;\n Console.WriteLine(b);\n }\n\no/p:Arthimetic overflow Error will occur unchecked block:it is used to disable overflow checking for arthimetic and conversion functions\n\nEx: unChecked\n\n{ byte b=254;\n\nb++;   b++;\n\nConsole.WriteLine(b);\n\n}\n\noutput:0\n\n\n\n### Question : Write a program to get the range of Byte Datatype?\n\nConsole.WriteLine(byte.MinValue);\n\nConsole.WriteLine(byte.MaxValue);\n\n### Question : What is the difference between typeOf() and sizeOf()?\n\nTypeOf() is used to get the Base Datatype name\n\nSizeOf() is used to get the size of the Datatype\n\n### Question : What is widening and Narrowing?\n\nWidening is used to convert smaller datatype to longer datatype\n\nEx:int to long\n\nNarrowing is used to convert longer datatype to smaller Datatype\n\nEx:long to int\n\nWorking with Narrowing is unsafe type of programming\n\n\n### Question : How to view an Assembly?\n\nStart----\u003eprograms----\u003eMSVS 2010-----\u003e\n\nVisualStudioTools----\u003eVisualStudioCommandPrompt----\u003etype ILDASM.exe\n\nILDASM:Intermediate Langauge DisAssembler\n\n\n### Question : How to implement Reflection in .Net?\n\nBy using System.Reflection Namespace and System.Type class\n\n### Question : What are MultiLingual Applications?\n\nThe Applications that are build in supportive of  more than one human Readble languages are known as MultiLingual Applications\n\n### Question : What is the difference between = and ==\n \n a=b assigning b value to a ; a==b comparing a with b; a.Equals(b) comparing two objects\n\n### Question : What is the use of Codesnippets?\n\ncode snippet is one of the best and easiest ways for any developer to increase code \nproductivity simply shortcuts\n\n### Question : What is the difference between Array and Collections?\n\nWe need to specify the size of the Array at the time of declaration but while Working with collections it is not required to mention the size of the Collection because the size of the collection will be fixed at runtime\n--\u003eThe members of the Array must be of same datatype but collections can have elements of Different datatypes\n\n### Question : What is the default Accessmodifier for the members of the class?\n\nPrivate\n\n### Question : What is the use of constructor?\n\nConstructor is used to initailze the userdefined values fro the variainstead of system defined values to the variables\n\n### Question : When the static constructor will be called?\n\nStatic constructor will be called before creating an object for a class.\nThe call to the static constructor will be done by CLR.\n\n### Question :  Can we declare Public accessmodifier for static constructor?\n\nNo\n\n### Question : if we declare Main() and static constructor in the same class  which one will be called first?\n\nStatic constructor\n\n### Question : How to Call the Default constructor of one class with the parameterised constructor of same class?\n\nby using this()\n\n### Question : How to access the constructors of one class to another class?\n\nby using base()\n\n### Question : Does C#.net Supports Multiple inheritance?\n\nNO\n\n### Question : How to acheive Multiple inheritance in C#.NET?\n\nBy using Multiple interfaces\n\n### Question : what is OverLoading?\n\nsame methodname+Different method signature in same class\n\n### Question : what is Overriding?\n\nsame methodheading+different method body in base class and derived class\n\n### Question : what is use of Properties?\n\nProperties are used to access the private datamembers of the class\n\n### Question : what is the Difference between Event and Method?\n\nEvent will not have returntype but method will have returntype\n\n### Question : what are Generics?\n\nGenerics are General Datatypes Generics will avoid TypeCasting like Boxing and UnBoxing\n\n### Question : Does generics supports Arthimetic Operators ?\n\nN0\n\n### Question : what is Dynamic Dispatch?\n\nDynamic Dispatch is concept that was introduced in .net 4.0 here the function call can be executed at runtime.\n\n### Question : Which of the following are Build in generic Types?  \n\nNullable\n\nEventHandlers\n \n### Question : In .net for Assemblies we are having StrongName lly in COM Components  what is the Strongname?\n\nGUID(Globally Unique identifier)\n\n### Question : Is Versioning applicable to Private assemblies?\n\nNo\n\n### Question : Does .net supports Cross Language Interoparability in CAS?\n\nNo\n\n### Question: What is the importance of “this”keyword?\n\nNamespace this ex1\n{\nClass this ex1\n{\nPublic int a=5;\nPublic int b=5;\nVoid display(int a, int b)\n{\nThis. a=a+5;\nThis.b=b+5;\nConsole.uniteline(this.a);\nConsole.unitiline(this.b);\n}\nClass program\n{\nVoid main()\n{\nThis ex1   mc=this ex();\nmc.display(10,20);\nCon.readline();\n\n1. when were we have declared instance variable and local variable with the same class, with in the  method control will give the priority for variable to overcome that we have to access the  instance variables with the help of ”this” keyword\n\n2. this keyword is representing the current class instance namespace my program\n{\nClass myclass\n{\nPublic int a;\nPublic void show()\n{\nInt b;\nCon.wL(b);\nCon.WL(a);\n}\n}\nClass program\n{\nVoid main()\nMyclass mc=new myclass();\nmc.show();\ncon.Readline();\n\no/p  ERROR:- because local variable we should initialized with some value before accessing. \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# C# programs \n\n### Question: C# program to print prime numbers\n\nA prime number is not divisible by any other number apart from 1 and itself. So, we use this logic in this program to determine if a number is prime.\n\nusing System;\nnamespace SamplePrograms\n{    class PrimeNumber\n    {      public static void Main()\n        {       // Declare a boolean variable to determine is if a number is prime\n            bool isNumberComposite = false;\n            int j;\n            // Prompt the user to enter their target number\n            Console.WriteLine(\"Enter your Target?\");\n            // Read the target number and convert to integer\n            int target = Int32.Parse(Console.ReadLine());\n            // 1 is neither prime nor composite. So start at 2\n            for (int i = 2; i \u003c= target; i++)  \n            {       for (j = 2; j \u003c i; j++)\n                {       // A number is not prime if it is divisible by any other number, \n                    // other than 1 and itself.\n                    if (i % j == 0)\n                    {       isNumberComposite = true;\n                    // We can break out of the inner for loop as we know the number is not prime\n                        break;\n                    }                 }\n                // Print the number if it is not composite\n                if (!isNumberComposite)\n                    Console.Write(\"{0} \", j);\n                else\n                    isNumberComposite = false; }\n            // This line is to make the program wait for user input, \n            // instead of immediately closing\n            Console.ReadLine();\n        }     } } \n\n### Question: C# program to print even numbers\n\nThis is a sample C# program to print even numbers. There are 2 ways to to print even numbers.\n1. Start at Zero. Increment the value by 2, print it. Do this until you reach your target number.\n2. Start at Zero. Divide the number by 2. If the remainder is zero, then you know the number is even. So print it and then increment it by 1 and divide the number by 2 again. Repeat this until we reach our target number.\nThis program can also be used to print odd numbers by making a minor logic change. Initialize the targetNumber variable to 1 instead of 0. If you are using dividing logic, then print the number if the remainder is not zero. \n\nNote: This program will crash and throws an exception, if you enter a very big number or a string. To handle exceptions, we can make use of try catch blocks. We will look at this in another program.\n\nusing System;\nnamespace SamplePrograms\n{     class EvenNumbers\n    {      public static void Main()\n        {       // Prompt the user to enter a target number. Target number is the \n            // number untill which the user want to have even and odd numbers printed\n            Console.WriteLine(\"Please enter your target\");\n            // Declare a variable to hold the target number\n            int targetNumber = 0;\n            // Retrieve, Convert and store the target number\n            targetNumber = Convert.ToInt32(Console.ReadLine());\n            // Use a FOR or WHILE loop to print the even numbers, until our target number\n            for (int i = 0; i \u003c= targetNumber; i = i + 2)\n            {       Console.WriteLine(i);}\n            // You can also check if a number is even, by dividing it by 2.\n            //for (int i = 0; i \u003c= targetNumber; i++)\n            //{               if ((i % 2) == 0)  {         Console.WriteLine(i);    }}\n            // You can also use a while loop to do the same as shown below.\n            //int start = 0;\n            //while (start \u003c= targetNumber)\n            //{     Console.WriteLine(start);    start = start + 2;  }\n  // This line is to make the program wait for user input, instead of immediately closing\n            Console.ReadLine();\n        }     } }\n\t\n### Question: C# program to print fibonacci series\n\nA prime number is not divisible by any other number apart from 1 and itself. So, we use this logic in this program to determine if a number is prime.\nusing System;\nnamespace SamplePrograms\n{    class FibonacciSeries\n    {      public static void Main()\n        {       // Prompt the user to enter their target number\n            Console.WriteLine(\"How many numbers do you want in the fibonacci series\");\n            // Read the user input from console and convert to integer\n            int Target = int.Parse(Console.ReadLine());\n            // Create integer variables to hold previous and next numbers\n            int PreviousNumber = -1, NextNumber = 1;\n            // This for loop controls the number of fibonacci series elements\n            for (int i = 0; i \u003c Target; i++)\n            {       // Logic to compute fibonacci series numbers\n                int Sum = PreviousNumber + NextNumber; \n                PreviousNumber = NextNumber;\n                NextNumber = Sum;\n                Console.Write(NextNumber + \"  \");\n            }\n            Console.ReadLine();    }   }  }\nA prime number is not divisible by any other number apart from 1 and itself. So, we use this logic in this program to determine if a number is prime.\n\n### Question: Palindrome program in C#\n\nA palindrome number is a number that is same after reverse. For example 121, 34543, 343, 131, 48984 are the palindrome numbers.\n\nPalindrome number algorithm\no\tGet the number from user\no\tHold the number in temporary variable\no\tReverse the number\no\tCompare the temporary number with reversed number\no\tIf both numbers are same, print palindrome number\no\tElse print not palindrome number\n\nLet's see the palindrome program in C#. In this program, we will get an input from the user and check whether number is palindrome or not.\n\tusing System;  \n\t  public class PalindromeExample  \n\t   {       public static void Main(string[] args)  \n\t      { \t          int n,r,sum=0,temp;    \t          Console.Write(\"Enter the Number: \");   \n          n = int.Parse(Console.ReadLine());  \t          temp=n;      \t          while(n\u003e0)      \n          {      \t           r=n%10;      \t           sum=(sum*10)+r;      \t           n=n/10;   \t          }      \n          if(temp==sum)   Console.Write(\"Number is Palindrome.\");               else      \n           Console.Write(\"Number is not Palindrome\");     \t    }  \t  }  \n\nOutput:\n\nEnter the Number=121   \n\nNumber is Palindrome.\n\nEnter the number=113  \n\nNumber is not Palindrome.\n\n### Question: Armstrong Number in C#\n\nBefore going to write the C# program to check whether the number is Armstrong or not, let's understand what is Armstrong number.\nArmstrong number is a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers.\n\nLet's try to understand why 371 is an Armstrong number.\n\n1.\t371 = (3*3*3)+(7*7*7)+(1*1*1)      \n\n2.\twhere:      \n\n3.\t(3*3*3)=27      \n\n4.\t(7*7*7)=343      \n\n5.\t(1*1*1)=1      \n\n6.\tSo:      \n\n7.\t27+343+1=371      \n\nLet's see the C# program to check Armstrong Number.\n\nusing System;  \n\t  public class ArmstrongExample  \n\t   {  \t     public static void Main(string[] args)  \n\t      {  \t       int  n,r,sum=0,temp;      \t       Console.Write(\"Enter the Number= \");      \n\t       n= int.Parse(Console.ReadLine());     \t       temp=n;      \n       while(n\u003e0)      \t       {      \t        r=n%10;      \t        sum=sum+(r*r*r);      \n\t        n=n/10;      \t       }      \n\t       if(temp==sum)      \t        Console.Write(\"Armstrong Number.\");      \n       else      \t        Console.Write(\"Not Armstrong Number.\");       }  \t  }  \n\n\nOutput:\n\nEnter the Number= 371\nArmstrong Number.\nEnter the Number= 342   \nNot Armstrong Number.\n\n### Question: C# Program to reverse number\n\nWe can reverse a number in C# using loop and arithmetic operators. In this program, we are getting number as input from the user and reversing that number.\nLet's see a simple C# example to reverse a given number.\n\tusing System;  \n\t  public class ReverseExample  \n\t   {  \t     public static void Main(string[] args)  \n\t      {  \t       int  n, reverse=0, rem;           \n\t       Console.Write(\"Enter a number: \");      \n\t       n= int.Parse(Console.ReadLine());     \n\t       while(n!=0)      \n\t       {     rem=n%10;         reverse=reverse*10+rem;    n/=10;       \n\t       }      \t      \n\t       Console.Write(\"Reversed Number: \"+reverse);       \n\t       }  \t\n\t       }  \n\nOutput:\n\nEnter a number: 234  \nReversed Number: 432\n\n### Question: C# Program to generate Fibonacci Triangle\n\nIn this program, we are getting input from the user for the limit for fibonacci triangle, and printing the fibonacci series for the given number of times (limit).\n\nLet's see the C# example to generate fibonacci triangle.\n\tusing System;  \n\t  public class PrintExample  \n\t   {  \t     public static void Main(string[] args)  \n\t      {  \t       int a=0,b=1,i,c,n,j;      \t\n\t      Console.Write(\"Enter the limit: \");    \n\t       n= int.Parse(Console.ReadLine());     \t   \n\t       for(i=1; i\u003c=n; i++)      \n\t       {  \t      \n\t       a=0;         \n\t       b=1;       \n\t       Console.Write(b+\"\\t\");     \n\t        for(j=1; j\u003ci; j++)    \t       \n {           \n c=a+b;         \n Console.Write(c+\"\\t\");      \n a=b;       \n b=c;    \n }      \n        Console.Write(\"\\n\");      \t   \n\t} \n\t} \n\t}  \n\t\n### Question: C# Program to Convert Number in Characters\n\nIn C# language, we can easily convert number in characters by the help of loop and switch case. In this program, we are taking input from the user and iterating this number until it is 0. While iteration, we are dividing it by 10 and the remainder is passed in switch case to get the word for the number.\n\nLet's see the C# program to convert number in characters.\n\tusing System;  \n\t  public class ConversionExample  \n\t   {  \t     public static void Main(string[] args)  \n\t      {  \t       int n,sum=0,r;          Console.Write(\"Enter the Number= \");    \n\t       n= int.Parse(Console.ReadLine());     \t       while(n\u003e0)      \n\t       {            r=n%10;            sum=sum*10+r;       n=n/10;             }      \n       n=sum;      \t       while(n\u003e0)        {       r=n%10;        switch(r)      {        case 1: \t         Console.Write(\"one \");  \t         break;      \n\t         case 2:               Console.Write(\"two \");   \t         break;      \n\t         case 3:              Console.Write(\"three \");    \t         break;      \n\t         case 4:              Console.Write(\"four \");    \t         break;      \n\t         case 5:              Console.Write(\"five \");    \t         break;      \n\t         case 6:               Console.Write(\"six \");     \t         break;      \n\t         case 7:    \t         Console.Write(\"seven \");    \t         break;    \n\t         case 8:               Console.Write(\"eight \");      \t         break;      \n\t         case 9:               Console.Write(\"nine \");    \t         break;      \n\t         case 0:              Console.Write(\"zero \");    \t         break;      \n\t         default:               Console.Write(\"tttt \");      \t         break;      \n\t        }//end of switch     \n\t        n=n/10;      \n\t       }//end of while loop       \n\t   }  \n\t   }  \n\nOutput:\nEnter the Number= 357546\nthree five seven five four six\n\n### Question: C# Program to print Number Triangle\n\nLike alphabet triangle, we can write the C# program to print the number triangle. The number triangle can be printed in different ways.\nLet's see the C# example to print number triangle.\n\tusing System;  \n\t  public class PrintExample  \n\t   {  \t     public static void Main(string[] args)  \n\t      {  \t       int  i,j,k,l,n;           \n\t       Console.Write(\"Enter the Range=\");    \t       n= int.Parse(Console.ReadLine());     \n\t       for(i=1; i\u003c=n; i++)      \n\t       {          \t        for(j=1; j\u003c=n-i; j++)      \n\t        {      \t         Console.Write(\" \");      \t        }      \n\t        for(k=1;k\u003c=i;k++)      \n\t        {      \t         Console.Write(k);      \t        }      \n\t        for(l=i-1;l\u003e=1;l--)      \n\t        {      \t        Console.Write(l);      \t        }      \n\t        Console.Write(\"\\n\");      \n\t       }       \t   }  \t  }  \nOutput:\nEnter the Range=5\n     1\n    121\n   12321\n  1234321\n 123454321  \nEnter the Range=6\n      1\n     121\n    2321\n   1234321 \n  123454321\n 12345654321 \n\n### Question: C# Program to swap two numbers without third variable\n\nWe can swap two numbers without using third variable. There are two common ways to swap two numbers without using third variable:\n1.\tBy + and -\n2.\tBy * and /\n\nProgram 1: Using ∗ and /\n\nLet's see a simple C# example to swap two numbers without using third variable.\n\nusing System;  \n\t  public class SwapExample  \n\t   {  \t     public static void Main(string[] args)  \n\t      {  \t       int  a=5, b=10;            \n\t       Console.WriteLine(\"Before swap a= \"+a+\" b= \"+b);    \n\t       a=a*b; //a=50 (5*10)      \n\t       b=a/b; //b=5 (50/10)      \n\t       a=a/b; //a=10 (50/5)    \n\t       Console.Write(\"After swap a= \"+a+\" b= \"+b);       \n\t     }  \t\n\t     }   \nOutput:\n\nBefore swap a= 5 b= 10     \nAfter swap a= 10 b= 5\n\n### Question: Program 2: Using + and -\n\nLet's see another example to swap two numbers using + and -.\n\tusing System;  \n\t  public class SwapExample  \n\t   {  \t     public static void Main(string[] args)  \n\t      {  \t       int  a=5, b=10;            \n\t       Console.WriteLine(\"Before swap a= \"+a+\" b= \"+b);    \n\t       a=a+b; //a=15 (5+10)      \n\t       b=a-b; //b=5 (15-10)      \n\t       a=a-b; //a=10 (15-5)   \n\t       Console.Write(\"After swap a= \"+a+\" b= \"+b);       \n\t      }  \t  }  \n\nOutput:\nBefore swap a= 5 b= 10     \nAfter swap a= 10 b= 5\n\n### Question: Decimal to Binary Conversion Algorithm\n\nStep 1: Divide the number by 2 through % (modulus operator) and store the remainder in array\n\nStep 2: Divide the number by 2 through / (division operator)\n\nStep 3: Repeat the step 2 until the number is greater than zero\n\nLet's see the C# example to convert decimal to binary.\n\tusing System;  \n\t  public class ConversionExample  \n\t   {  \t \n\t   public static void Main(string[] args)  \n\t      {  \t       int  n, i;       \n\t       int[] a = new int[10];     \n\t       Console.Write(\"Enter the number to convert: \");    \n\t       n= int.Parse(Console.ReadLine());     \n\t       for(i=0; n\u003e0; i++)      \n\t        {      \t         a[i]=n%2;             n= n/2;            }      \n\t       Console.Write(\"Binary of the given number= \");      \n\t       for(i=i-1 ;i\u003e=0 ;i--)      \n\t       {              Console.Write(a[i]);    \n\t       }\n\t       }\n\t       }  \n\t       \nOutput:\n\nEnter the number to convert:10\nBinary of the given number= 1010 \n\n### Question: C# Program to Convert Number in Characters\n\nIn C# language, we can easily convert number in characters by the help of loop and switch case. In this program, we are taking input from the user and iterating this number until it is 0. While iteration, we are dividing it by 10 and the remainder is passed in switch case to get the word for the number.\n\nLet's see the C# program to convert number in characters.\n\nusing System;  \n\t  public class ConversionExample  \n\t   {  \t     public static void Main(string[] args)  \n\t      {  \t       int n,sum=0,r;     \n\t       Console.Write(\"Enter the Number= \");    \n       n= int.Parse(Console.ReadLine());     \n\t       while(n\u003e0)      \n\t       {             r=n%10;            sum=sum*10+r;          n=n/10;             }      \n\t       n=sum;      \n\t       while(n\u003e0)      \n\t       {           r=n%10;      \n\t        switch(r)      \n\t        {              case 1:           Console.Write(\"one \");           break;      \n\t         case 2:              Console.Write(\"two \");      \t         break;      \n\t         case 3:              Console.Write(\"three \");    \t         break;      \n\t         case 4:               Console.Write(\"four \");    \t         break;      \n\t         case 5:               Console.Write(\"five \");    \t         break;      \n\t         case 6:               Console.Write(\"six \");     \t         break;      \n\t         case 7:    \t         Console.Write(\"seven \");    \t         break;    \n\t         case 8:              Console.Write(\"eight \");      \t         break;      \n\t         case 9:               Console.Write(\"nine \");    \t         break;      \n\t         case 0:              Console.Write(\"zero \");    \t         break;      \n\t         default:               Console.Write(\"tttt \");      \t         break;      \n\t        }//end of switch      \n\t        n=n/10;      \n\t       }//end of while loop       \n\t   }  \t  }  \n\nOutput:\n\nEnter the Number= 357546\nthree five seven five four six\n\n### Question: C# program to print multiplication table\n\nThis program can be used to print any multiplication table until any number\n\nusing System;\nnamespace SamplePrograms\n{    class NumberTable\n    {      public static void Main()\n        {       // Prompt the user to enter number for multiplication table\n            Console.WriteLine(\"For which number do you want to print multiplication table\");\n            // Read the number from console and convert to integer\n            int Number = Convert.ToInt32(Console.ReadLine());\n            // Prompt the user for multiplication table target\n            Console.WriteLine(\"What is your target? 10, 20, 30 etc...\");\n            // Read the target from console and convert to integer\n            int Target = Convert.ToInt32(Console.ReadLine());\n            // Loop to print multiplication table until we reach the target\n            for (int i = 1; i \u003c= Target; i++)\n            {       // Compute multiplication result\n                int Result = Number * i;\n                // Format and Print the multiplication table\n                Console.WriteLine(Number.ToString() + \" X \" + i.ToString() + \n                                  \" = \" + Result.ToString());\n                // The above line can also be rewritten as shown below.\n                // Console.WriteLine(\"{0} X {1} = {2}\", Number, i, Result);\n            }      \n\t    }\n\t    }\n\t    }\n\n### Question: C# program to print alphabets\n\nThis c# program prints both upper and lower case alphabets using 2 different approaches.\n\nusing System;\nnamespace SamplePrograms\n{    class Alphabets\n    {        public static void Main()\n        {            // Loop from a thru z (lower case alphabets)\n            for (char alphabet = 'a'; alphabet \u003c= 'z'; alphabet++)\n            {       Console.Write(alphabet + \" \");            }\n            //Another way to print lower case alphabets\n            //for (int i = 0; i \u003c 26; i++)\n            //{    Console.Write(Convert.ToChar(i + (int)'a') + \" \");   }\n            Console.WriteLine();\n            // Loop from A thru Z (upper case alphabets)\n            for (char alphabet = 'A'; alphabet \u003c= 'Z'; alphabet++)\n            {               Console.Write(alphabet + \" \");            }\n            //Another way to print uppercase case alphabets\n            //for (int i = 0; i \u003c 26; i++)\n            //{             Console.Write(Convert.ToChar(i + (int)'A') + \" \");     }\n            Console.ReadLine();      \n\t    }\n\t    }\n\t    }\n\t    \n### Question: Power function in C#\n\nWrite a Power() function. The function should take 2 parameters - Base and Exponent. The function should return back the result of \"Base raised to the power of exponent\". Let me give an example.\nWhen the Power() method is called using parameters 3 and 4 as shown below. The value of 3 to the power of 4 should be returned back, i.e 81.\nSo in short Power(3,4) should return 81. So in this example 3 is the base and 4 is the exponent.\n\nusing System;\nnamespace SamplePrograms\n{    class PowerFunction\n    {      public static void Main()\n        {       // Prompt the user to enter base\n            Console.WriteLine(\"Enter your base\");\n            int Base = Convert.ToInt32(Console.ReadLine());\n            // Prompt the user to enter exponent\n            Console.WriteLine(\"Enter your exponent\");\n            int Exponent = Convert.ToInt32(Console.ReadLine());\n            // Call the power method passing it Base and Exponent\n            int Result = Power(Base, Exponent);\n            // In System.Math class there is Pow() static method which is\n            // very similar to the static Power() method we implemented\n            // double Result = System.Math.Pow(Base, Exponent);\n            // Print the result\n            Console.WriteLine(\"Result = {0}\", Result);\n        }\n        public static int Power(int Base, int Exponent)\n        {            // Declare a variable to hold the result\n            int Result = 1;\n            // Multiply the Base number with itself, for \n            // exponent number of times\n            for (int i = 1; i \u003c= Exponent; i++)\n            {       Result = Result * Base;         }\n            //return the Result\n            return Result;\n        }   \n\t}\n\t}\n\t\n### Question: C# program to count emails by domain\n\nI have a string of emails seperated by semi colon as shown below. \nstring UserInputEmails = \"aa@xyz.com;cc@abc.com;bb@abc.com;dd@abc.com\";\nWrite a c# program, that lists the total number of emails by domain. The program should give the following output.\nDomain = xyz.com \u0026 Count = 1\nDomain = abc.com \u0026 Count = 3\n\nusing System;\nusing System.Linq;\nnamespace SamplePrograms\n{    class CountEmailsByDomain\n    {        public static void Main()\n        {       // User List of emails seperated by semi colon. You can have as many\n            // number of emails you want in this string.\n            string UserInputEmails = \"aa@xyz.com;cc@abc.com;bb@abc.com;dd@abc.com\";\n            // Split the string into a string array.\n            string[] UserEmails = UserInputEmails.Split(';');\n            // Select only the domain part of the emails into a string array, using substring() function\n            string[] EmailsDomain = UserEmails.Select(x =\u003e x.Substring(x.LastIndexOf(\"@\") + 1)).ToArray();\n            // Group the emails by email domain, and select the Domain and respective count\n            var Result = EmailsDomain.GroupBy(x =\u003e x).Select(y =\u003e new { Domain = y.Key, Count = y.Count() });\n            // Finally print the domain name and the emails count\n            foreach (var obj in Result)\n            {       Console.WriteLine(\"Domain = {0} \u0026 Count = {1}\",obj.Domain, obj.Count); \n\t    }\n\t    }\n\t    }\n\t    }\n\t    \nBuild a simple calculator using c# programming language. The calculator should have the following features.\n1. Adding 2 Numbers\n2. Subtracting 2 Numbers\n3. Multiplying 2 Numbers\n4. Dividing 2 Numbers\n\nAlso, the program should run as long as the user wants it to be running.\n\nusing System;\nnamespace SamplePrograms\n{    class SimpleCalculator\n    {      public static void Main()\n        {       string UserSelection = string.Empty;\n            do\n            {       PrintMenu();\n                int UserChoice = Convert.ToInt32(Console.ReadLine());\n                while (UserChoice \u003c 1 || UserChoice \u003e 4)\n                {              Console.WriteLine(\"Invalid Option. Try again\");\n                    PrintMenu();                     Console.WriteLine();\n                    UserChoice = Convert.ToInt32(Console.ReadLine());\n                }\n                Calculate(UserChoice);\n                Console.WriteLine(\"Do you want to continue\");\n                UserSelection = Console.ReadLine();\n                while (UserSelection.ToUpper() != \"NO\" \u0026\u0026\n                  UserSelection.ToUpper() != \"YES\")\n                {              Console.WriteLine();\n                    Console.WriteLine(\"Invalid Input - Please type YES or NO\");\n                    Console.WriteLine(\"Do you want to continue\");\n                    UserSelection = Console.ReadLine();\n                }             }\n            while (UserSelection.ToUpper() != \"NO\");\n            Console.WriteLine();\n            Console.WriteLine(\"The program will now terminate\");\n        }\n        public static void PrintMenu()\n        {            Console.WriteLine();\n            Console.WriteLine(\"Select your option\");\n            Console.WriteLine(\"------------------\");\n            Console.WriteLine(\"1. Addition\");\n            Console.WriteLine(\"2. Subtraction\");\n            Console.WriteLine(\"3. Multiplication\");\n            Console.WriteLine(\"4. Division\");\n            Console.WriteLine();\n        }\n        public static void Calculate(int SelectedOption)\n        {            int Result = 0;\n            Console.WriteLine(\"Enter your first number\");\n            int FirstNumber = Convert.ToInt32(Console.ReadLine());\n            Console.WriteLine(\"Enter your second number\");\n            int SecondNumber = Convert.ToInt32(Console.ReadLine());\n            Console.WriteLine();\n            switch (SelectedOption)\n            {       case 1:\n                    Result = FirstNumber + SecondNumber;\n                    Console.WriteLine(\"{0} + {1} = {2}\", FirstNumber, SecondNumber, Result);\n                    break;\n                case 2:\n                    Result = FirstNumber - SecondNumber;\n                    Console.WriteLine(\"{0} - {1} = {2}\", FirstNumber, SecondNumber, Result);\n                    break;\n                case 3:\n                    Result = FirstNumber * SecondNumber;\n                    Console.WriteLine(\"{0} * {1} = {2}\", FirstNumber, SecondNumber, Result);\n                    break;\n                case 4:\n                    Result = FirstNumber / SecondNumber;\n                    Console.WriteLine(\"{0} / {1} = {2}\", FirstNumber, SecondNumber, Result);\n                    break;\n            }      \n\t    } \n\t    } \n\t    }\n\n### Question: Reverse characters in a string\n\nWrite a C# program to print the characters in a string in the reverse order.\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\nnamespace SamplePrograms\n{     class ReverseCharacters\n    {      public static void Main()\n        {       // Prompt the user to enter the string\n            Console.WriteLine(\"Please enter your string\");\n            // Read the user string from console\n            string UserString = Console.ReadLine();\n            // The simple way to reverse a string is to use\n            // the built-in .net framework Reverse() function\n            List\u003cchar\u003e StringCharacters = UserString.Reverse().ToList();\n            // Finally print each character from the collection\n            foreach (char c in StringCharacters)\n            {       Console.Write(c);         }\n            Console.WriteLine();\n            Console.ReadLine();\n        }  \n\t}\n\t}\n\n### Question: C# program to sort names in ascending and descending order\n\nI have a string of user names seperated by semi colon. I want a c# program that can sort these names in both ascending and descending order.\n\nstring strUserNames = \"Rob;Mike;Able;Sara;Peter;John;Tom;Ben\";\nusing System;\nnamespace SamplePrograms\n{    class SortNamesInAscendingAndDescendingOrder\n    {      public static void Main()\n        {       // Prompt the user to enter the list of user names\n            Console.WriteLine(\"Please enter list of names seperated by semi colon\");         \n            // Read the user name list from the console\n            string strUserNames = Console.ReadLine();\n            // Sampe list of user names that can be used as an input\n            // strUserNames = \"Rob;Mike;Able;Sara;Peter;John;Tom;Ben\";\n            // Split the string into a string array based on semi colon\n            string[] arrUsersNames = strUserNames.Split(';');\n            // Print the names before sorting using foreach loop\n            Console.WriteLine(\"Names before sorting\");\n            foreach (string UserName in arrUsersNames)\n            {                Console.WriteLine(UserName);               }\n            // Sort the elements in the array in ascending order\n            Array.Sort(arrUsersNames);\n            // Print the elements of the array after sorting\n            Console.WriteLine(\"Names after sorting in ascending order\");\n            foreach (string UserName in arrUsersNames)\n            {                 Console.WriteLine(UserName);             }\n            // Reverse the elements in the sorted array to get\n            // the elements in descending order\n            Array.Reverse(arrUsersNames);\n            // Finally print the elements\n            Console.WriteLine(\"Names after sorting in descending order\");\n            foreach (string UserName in arrUsersNames)\n            {                 Console.WriteLine(UserName);             }\n            Console.ReadLine();\n        } \n\t}\n\t}\n\t\n### Question: C# program to remove duplicates\n\nWrite a c# program to print unique names, by removing the duplicate entries. For example, in the Input String below, Rob and Able names are repeated twice. The c# program that you write should remove the duplicates and return the string as shown in Output String. The output string contains each name only once, eliminating duplicates.\nInput String    = \"Rob;Mike;Able;Sara;Rob;Peter;Able;\"\nOutput String = \"Rob;Mike;Able;Sara;Peter;\"\nusing System;\nusing System.Linq;\nusing System.Text;\nnamespace SamplePrograms\n{    class PrintUniqueNames\n    {      public static void Main()\n        {       // Prompt the user to enter the list of user names\n            Console.WriteLine(\"Please enter list of names seperated by semi colon\");\n            // Read the user name list from the console\n            string strUserNames = Console.ReadLine();\n            // Sampe list of user names that can be used as an input\n            // strUserNames = \"Rob;Mike;Able;Sara;Rob;Peter;Able\";\n            // Split the string into a string array based on semi colon\n            string[] arrUsersNames = strUserNames.Split(';');\n            // Use the Distinct() LINQ function to remove duplicates\n            string[] arrUniqueNames = arrUsersNames.Distinct().ToArray();\n            // Using StringBuilder to concatenate strings is more efficient\n            // than using immutable string objects for better performance\n            StringBuilder sbUniqueUsernames = new StringBuilder();\n            // Build the string from unique names appending semi colon\n            foreach (string strName in arrUniqueNames)\n            {       sbUniqueUsernames.Append(strName + \";\");  }\n            // Remove the extra semi colon in the end\n           sbUniqueUsernames.Remove(sbUniqueUsernames.ToString().LastIndexOf(';'), 1);\n            // Finally print the unique names\n            Console.WriteLine();\n            Console.WriteLine(\"Printing names without duplicates\");\n            Console.WriteLine(sbUniqueUsernames.ToString());\n        }     } }\n\t\n\t\n### Question: Insert space before every upper case letter in a string\n\nWrite a c# program that inserts a single space before every upper case letter. For example, if I have string like \"ProductUnitPrice\", the program should convert it to \"Product Unit Price\". Usually database column names will not have spaces, but when you display them to the user, it makes sense to have spaces.\n\nusing System;\nusing System.Text;\nnamespace SamplePrograms\n{    class SpaceBeforeUpperCaseLetter\n    {      public static void Main()\n        {       // Prompt the user for input\n            Console.WriteLine(\"Please enter your string\");\n            // Read the input from the console\n            string UserInput = Console.ReadLine();\n            // Convert the input string into character array\n            char[] arrUserInput = UserInput.ToCharArray();\n            // Initialize a string builder object for the output\n            StringBuilder sbOutPut = new StringBuilder();\n            // Loop thru each character in the string array\n            foreach (char character in arrUserInput)\n            {       // If the character is in uppercase\n                if (char.IsUpper(character))\n                {       // Append space\n                    sbOutPut.Append(\" \");         }\n                // Append every charcter to reform the output\n                sbOutPut.Append(character);        }\n            // Remove the space at the begining of the string\n            sbOutPut.Remove(0, 1);\n            // Print the output\n            Console.WriteLine(sbOutPut.ToString());\n            Console.ReadLine();\n        }     }    }\n\t\nException handling at its best\n\n### Question: Write a c# program to add two numbers. \n\nThis may sound very simple, but the catch, is - The program should not break, and always should give meaningful error messages when exception conditions occur. For example, the following error conditions should be handled in your program. Also, the program should run as long as the user wants it to run.\n1. If the user enters \"Ten\" instead of 10, the program should let the user know only numbers can be added.\n2. If the user, enters a very large number, the program should let the user know about the range allowed.\nusing System;\nnamespace SamplePrograms\n{     class ExceptionHandlingAtItsBest\n    {        public static void Main()\n        {             string strUserChoice = String.Empty;\n            do\n            {      try\n                {       Console.WriteLine(\"Please enter first number\");\n                    int FN = Convert.ToInt32(Console.ReadLine());\n                    Console.WriteLine(\"Please enter second number\");\n                    int SN = Convert.ToInt32(Console.ReadLine());\n                    int Total = FN + SN;\n                    Console.WriteLine(\"Total = {0}\", Total);\n                }\n                catch (FormatException)\n                {         Console.WriteLine(\"Invalid Input. Only numbers please.\");               }\n                catch (OverflowException)\n                {                    Console.WriteLine(\"Only numbers between {0} and {1} are allowed\", \n                        Int32.MinValue, Int32.MaxValue);                 }\n                catch (Exception)\n                {         Console.WriteLine(\"Unknown problem, please contact administrator\");            }\n                do\n                {           Console.WriteLine(\"Do you want to continue - Yes or No\");\n                    strUserChoice = Console.ReadLine();\n                } \n      while (strUserChoice.ToUpper() != \"YES\" \u0026\u0026 strUserChoice.ToUpper() != \"NO\");\n            } \n            while (strUserChoice.ToUpper() != \"NO\");\n        }     }   }\n\t\n### Question: Find smallest and largest number in an integer array\n\nI want a c# program that can find and print, the smallest and largest number in a given integer array.\nusing System;\nusing System.Linq;\nnamespace SamplePrograms\n{    class LargestSmallest\n    {      public static void Main()\n        {       // Declare and initialize the integer array\n            int[] NumbersArray = { 102, 34, 89, 12, 187, 29, 111};\n            // Sort the array, first element in the array will be\n            // smallest and the last element will be largest\n            Array.Sort(NumbersArray);\n            // Print the smallest number in the array\n            Console.WriteLine(\"Samllest Number = {0}\", NumbersArray[0]);\n            // Print the largest number in the array.\n            Console.WriteLine(\"Largest Number = {0}\", NumbersArray[NumbersArray.Length -1]);\n            // Linq makes this much easier, as we have Min() and Max() extension methods\n            // Console.WriteLine(\"Samllest Number = {0}\", NumbersArray.Min());\n            // Console.WriteLine(\"Largest Number = {0}\", NumbersArray.Max());\n        }     } }\n\t\n### Question: C# Program to compute factorial of a number\n\nIn mathematics, 5 factorial is computed as 5X4X3X2X1, which is equal to 120. 5 factorial is denoted as 5 and an exclamation mark as shown below.\n\n5 Factorial = 5! = 5X4X3X2X1 = 120 \n4 Factorial = 4! = 4X3X2X1 = 24\n3 Factorial = 3! = 3X2X1 = 6\nFactorial of Zero is 1.\n\nC# Program below shows how to compute factorial for a given number. If you like this artcile, please click g+1 button below to share with your friends.\n\nusing System;\nnamespace SamplePrograms\n{     class Factorial\n    {      public static void Main()\n        {       // Prompt the user to enter their target number to calculate factorial\n  Console.WriteLine(\"Please enter the number for which you want to compute factorial\");\n            try\n            {       // Read the input from console and convert to integer data type\n                int iTargetNumber = Convert.ToInt32(Console.ReadLine());\n                // Factorial of Zero is 1\n                if (iTargetNumber == 0)\n                {       Console.WriteLine(\"Factorial of Zero = 1\");                }\n                // Compute factorial only for non negative numbers\n                else if (iTargetNumber \u003c 0)\n                {           Console.WriteLine(\"Please enter a positive number greater than 1\");                }\n                // If the number is non zero and non negative\n                else\n                {            // Declare a variable to hold the factorial result.\n                    double dFactorialResult = 1;\n                    // Use for loop to calcualte factorial of the target number\n                    for (int i = iTargetNumber; i \u003e= 1; i--)\n                    {                        dFactorialResult = dFactorialResult * i;                    }\n                    // Output the result to the console\n      Console.WriteLine(\"Factorial of {0} = {1}\", iTargetNumber, dFactorialResult);\n                }            }\n            catch (FormatException)\n            {                // We get format exception if user enters a word instead of number\n            Console.WriteLine(\"Please enter a valid number\", Int32.MaxValue);   }\n            catch (OverflowException)\n            {                // We get overflow exception if user enters a very big number, \n                // which a variable of type Int32 cannot hold\n                Console.WriteLine(\"Please enter a number between 1 and {0}\", Int32.MaxValue);   }\n            catch (Exception)\n            {                // Any other unforeseen error\n                Console.WriteLine(\"There is a problem! Please try later\");\n\t\t} \n\t\t}\n\t\t}\n\t\t}\n\t\t\n\t\t\n### Question: How to get the total number of decimal places using c#\n\nFor example, please refer to the sample input and output below. \nInput\tOutput\n1\t0\n1.0\t0\n1.1\t1\n1.12\t2\n1.123\t3\n1.1100\t2\n1.010\t2\n1.001100 \t4   \n\n\nusing System;\nnamespace SampleProgram\n{     class MainProgram\n    {      public static void Main(string[] args)\n        {       // Create the decimal array for sample test data\ndecimal[] decimalNumbers = { 1, 1.0M, 1.1M, 1.12M, 1.123M, 1.1100M,                                               1.010M, 1.001100M };\n            // Loop thru each decimal number\n            foreach (decimal decimalNumber in decimalNumbers)\n            {            // Print the original number and total decimal places\n                Console.WriteLine(\"Original Decimal Number = {0}, Total Decimal Places = {1}\",\n                    decimalNumber, GetDecimalPartCount(decimalNumber));\n            }         }\n        // Function that return the total decimal places\n        private static int GetDecimalPartCount(decimal decimalNumber)\n        {            // Dividing decimal number with 1 gives the decimal part\n            decimal decimalPlaces = decimalNumber % 1;\n            if (decimalPlaces != 0)\n            {       // Get the index of dot from the decimal part\n                int indexOfDot = decimalPlaces.ToString().IndexOf('.');\n                // Use the 0.######## format string to rip off trailing zeros, and get the count\n                int numberOfDecimals =\n                decimalPlaces.ToString(\"0.##########\").Substring(indexOfDot).Length - 1;\n                return numberOfDecimals;\n          }\n            // Finally convert decimal to int and return\n            return (int)decimalPlaces;\n        }    \n\t}  \n\t}\n\t\n### Question: How to remove trailing zeros in a decimal - C# Program\n\nFor example, consider the sample input and expected output below.\nInput\tOutput\n1.0\t1\n1.01\t1.01\n1.0010\t1.001\n0.00\t0\n1.0050   \t1.005     \n\nusing System;\nnamespace SampleProgram\n{    class MainProgram\n    {      public static void Main(string[] args)\n        {       decimal[] decimalNumbers = { 1.0M, 1.01M, 1.0010M, 0.00M, 1.0050M};\n            foreach (decimal decimalNumber in decimalNumbers)\n            { Console.WriteLine(\"Original Decimal Number = {0}, Without Zeros = {1}\",\n                                    decimalNumber, decimalNumber.ToString(\"0.####\"));\n           \n\t   } \n\t   } \n\t   }\n\t   }\n\t   \nIf I enter 1.1234567890, we get 1.1235, instead of 1.123456789. This is because, the number of # symbols in the ToString(\"0.####\") is only 4. The maximum decimal places, you want in the output is represented by the # symbol. In general a C# decimal datatype can have 29 total number of digits. This includes both integral and decimal part of a decimal.\n\n### Question: Write a c program to print M pattern\n*                  *\n**                **\n* *              * *\n*  *            *  *\n*   *          *   *\n*    *        *    *\n*     *      *     *\n*      *    *      *\n*       *  *       *\n*        **        *\n*                    *\n\n#include \u003ciostream\u003e\nusing namespace std;\n void printM(int height, int width)\n{    for(int row = 0; row \u003c height; row++)\n    {      for(int col = 0; col \u003c width; col++)\n        {       if(col == 0 || col == width - 1 || ((col == row || col == width - row - 1) \u0026\u0026 row \u003c height / 2) )\n                cout \u003c\u003c \"*\";\n            else\n               cout \u003c\u003c \" \";\n        }\n        cout \u003c\u003c endl;\n    } }\n int main() {    printM(20, 20);    return 0;}\n20.write   the o/p for the below program?\nname space console APPLICATION\n{Class Myclass\n{Int a=10;}\nClass program\n{Static v.main()\n{Myclass mc=new myclass()\nCon.WL(mc.a);\nCon.RL();\n} } }\n\t\t    \nOutput is compile time error because bydefault accesmodifier of a instance variable(Non-static)is private.which we can access only with in that class\n\n### Question: Write the o/p for the below program?\n\nNamespace program ex\n{Int a;\nString s;\nPublic void display()\n{Consoie.writeline(a);\nConsole.WL(s);\n} }\nClass program\n{Void main()\n{Myclass mc=new myclass();\nmc.display();\ncons.readline();\n}}\no/p 0\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### Interview rating Sheet\nWe have provided a self assessment rating sheet in the book for .NET, Networking, Project management, Architecture, SQL Server and lot more. If you are able get 80 % in the assessment we are sure you can crack any Interview. You can find the assessment sheet in CD as an excel file (InterviewRating.xls). So take the self test again and again to improve your confidence.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkansiris%2Fc-sharp-c-interview-question","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkansiris%2Fc-sharp-c-interview-question","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkansiris%2Fc-sharp-c-interview-question/lists"}