C# contains reserved words that have special meaning for the compiler these reserved words are called "keywords" keywords can't be used as identifier (name of variable, class, interface etc) there are 11 types of keywords. 1. Modifier Keywords 2. Access Modifier Keywords 3. Statement Keywords 4. Method Parameter Keywords 5. Namespace Keywords 6. Operator Keywords 7. Access Keywords 8. Literal Keywords 9. Type Keywords 10. Contextual Keywords 11. Query Keywords 1. Modifier Keywords : are the specific keywords that indicates which can modify types and type members. Example - Abstract, async, const, event, extern, new, override, partial, read-only, sealed, static, unsafe, virtual and volatile. 2. Access Modifier Keywords: are applied to the declaration of the class, methods, properties, fields and other member. they define the accessibility of the class and its members. there are basic four type of Access Modifier...
It is a new feature that has been added in C# 3.0 which allows us to add new methods into a class without editing the source code of the class i.e. if a class consists of a set of members in it and in the future if you want to add new methods into the class, you can add those methods without making any changes to the source code of the class. Extension methods can be used as an approach to extending the functionality of a class in the future if the source code of the class is not available or we don’t have any permission in making changes to the class. Before extension methods, inheritance is an approach that is used for extending the functionality of a class i.e. if we want to add any new members to an existing class without making a modification to the class, we will define a child class to that existing class and then we add new members in the child class. In the case of an extension method, we will extend the functionality of an existing class. In this case, we will create a new cl...
Ref - Ref is two ways from caller to callee and back. static void Main(string[] args) { int outSideVar = 10; GetNextNameByOut(out outSideVar); Console.WriteLine(outSideVar); } static void GetNextNameByOut(out int inSideVar) { inSideVar = inSideVar + 20; } Out - Data sent from the caller has been discarded and its mandatory to initialize the variables inside the callee. Out is a ne way from callee to caller. static void Main(string[] args) ...
Comments
Post a Comment