Posts

Extension Method & Partial Class

  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

 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#

 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#

Ref Vs Out Keyword

OOP Concepts C#