Posts
Extension Method & Partial Class
- Get link
- Other Apps
Extension - extension method allows you to add new methods in the existing class or in the structure without modifying the source code of the original type and you do not require any kind of special permission from the original type and there is no need to re-compile the original type. Partial Class- It provides a special ability to implement the functionality of a single class into multiple files and all these files are combined into a single class file when the application is compiled. A partial class is created by using a partial keyword. First(): it returns the first element from a sequence means when we query in a collection on specific criteria, if multiple elements are found in a collection of given criteria then the first element of a sequence will return. -First it can't handle the null value. var emp = Employee.GetAllEmp().Where(x => x.Name == "Ashutosh").First(); FirstOrDefault(): FirstOrDefault works same as First() does, FirstOrDefault returns the
Filters In MVC
- Get link
- Other Apps
Authentication Filters: Authentication filter runs before any other filter or action method. Authentication confirms that you are a valid or invalid user. Authorization Filters: Authorization Filters are responsible for checking User Access. These filters used to implement authentication and authorization for controller actions. Action Filters : Action Filter is an attribute that you can apply to a controller action or an entire controller. This filter will be called before and after the action starts executing and after the action has executed. Result Filters: The Output Cache Attribute class is an example of Result Filters. These implement the IResult Filter interface which like the IAction Filter has OnResult Executing and OnResult Executed. These filters contain logic that is executed before and after a view result is executed. Like if you want to modify a view result right before the view is rendered to the browser. Exception Filters : The HandleErrorAttribute class is an exa
String Program in C#
- Get link
- Other Apps
1)Reverse Name String in C# String Name="Sudam"; int Len=Name.Length-1; while(Len>=0) { Console.Write(Name[Len]); Len--; } ----------------------------------------- Output --madus ----------------------------------------- 2)Reverse Words of a String in C# string s = "I Name Is Sudam"; string[] a = s.Split(' '); int temp= a.Length - 1; while (temp >= 0) { Console.Write(a[temp] + ' '); temp--; } ------------------------------------------ Output --Sudam Is Name I ---------------------------------------- 3) How to Fine count how many double letters are in a string? int doubleLetters = 0; string characters = "Hello"; for (int i = 0; i < characters.Length - 1; i++) { if (characters[i] == characters[i + 1]) { doubleLetters++; i++; } Console.WriteLine(doubleLetters); } --------------------------------------------------------------------------------- 4] Find the second Max number in an array?
Popular posts from this blog
String Program in C#
1)Reverse Name String in C# String Name="Sudam"; int Len=Name.Length-1; while(Len>=0) { Console.Write(Name[Len]); Len--; } ----------------------------------------- Output --madus ----------------------------------------- 2)Reverse Words of a String in C# string s = "I Name Is Sudam"; string[] a = s.Split(' '); int temp= a.Length - 1; while (temp >= 0) { Console.Write(a[temp] + ' '); temp--; } ------------------------------------------ Output --Sudam Is Name I ---------------------------------------- 3) How to Fine count how many double letters are in a string? int doubleLetters = 0; string characters = "Hello"; for (int i = 0; i < characters.Length - 1; i++) { if (characters[i] == characters[i + 1]) { doubleLetters++; i++; } Console.WriteLine(doubleLetters); } --------------------------------------------------------------------------------- 4] Find the second Max number in an array?
Ref Vs Out Keyword
Ref Vs Out Keyword Ref vs Out Keyword in C# Ref- 1)R ef parameter should have the same value. 2)Ref keyword is used to pass an argument as a reference 3) No Need to initialize out parameter before passing it. Eg:=int a; 4) Out parameter must be initialized before returning. Out - 1)O ut parameters are not required to have value 2)Out keyword is also used to pass an argument like ref keyword 3)Must initialize Ref parameter else error. Eg:=int b=5; 4) Ref parameter initialized not necessary. When to use Out and Ref Parameter? 1)When you want to return more than one values from a method then you can use out and ref parameters.
OOP Concepts C#
Six Important C# Interview Questions & OOP Concepts 1. Encapsulation 2. Abstraction 3. Inheritance 4. Polymorphism 2) What is Encapsulation? How can we achieve? A) Wrapping STATES and BEHAVIOURS are called as ENCAPSULATION. Or Binding VARIABLES and METHODS is called as ENCAPSULATION. By implementing class we can achieve ENCAPSULATION. 3) What is abstraction? How can we achieve this? A) Abstraction means HIDING. Abstractions are 2 types. 1) data abstraction:- Hiding unwanted data is called as data abstraction 2) Method abstraction:- Invoking the required method and hiding unwanted method is called as method abstraction. With the help of FUNCTION OVERLOADING, we can achieve Method ABSTRACTION. 4) What is Inheritance? Types of Inheritance? A) Inheriting or deriving members from one class to another class is called as INHERITANCE. C#.Net will support 5 types of Inheritance. They are 1. Single Inheritance 2. Multi-level Inhe