
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

3K+ Views
NullReferenceException is a C# version of NullPointerException. To handle and catch it in C#, use try-catch.The below example shows that a variable is set to null and when we try to print it, it throws an exception that gets caught in the catch −Try { a = null; Console.WriteLine(a); }catch (NullPointerException ex) { Console.WriteLine("Variable is Null!"); }The above will allow the exception to be caught and use catch for it.

2K+ Views
Naming convetion for classesA class definition starts with the keyword class followed by the class name; and the class body enclosed by a pair of curly braces. The following are the conventions for class names.Pascal CasingThe coding conventions for a class name is the the name of the class names, for example, it should being PascalCasing.public class EmployeeDetails {}Above, the class name EmployeeDetails is in PascalCasing.Noun or Noun PhrasesPrefer adding class names as noun or noun phrases −public class Employee {} Identifier is a name used to identify a class, variable, function, or any other user-defined item.The following are the ... Read More

335 Views
One of the best tools for mutation testing in C# is “VisualMutator” It is integrated with the .NET programming environment.The following are the features of VisualMutant, which is a mutation test tool −Measure the quality of the test suite.To create first-order mutants using built-in and custom mutation operators.View modified code fragments in C#.Run NUnit and XUnit tests on generated mutants.Provides information about passed and failed testsYou can also write the results to XML.View details about any mutant right after the start of the mutation testing processIt gives results as mutation score

600 Views
Nested class is a class declared in another enclosing class. It is a member of its enclosing class and the members of an enclosing class have no access to members of a nested class.Let us see an example code snippet of nested classes in C# −Exampleclass One { public int val1; public class Two { public int val1; } } class Demo { static void Main() { One a = new One(); a.val1++; One.Two ab = new One.Two(); ... Read More

5K+ Views
A property is optional if it is possible and valid for it to have null. A property whose CLR type cannot have null cannot be configured optional.An example optional attribute usage −Example[AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)] internal sealed class OptionalAttribute : Attribute { } public class Employee { public string EmpName { get; set; } [Optional] public string AlternativeName { get; set; } }

6K+ Views
Private access specifier allows a class to hide its member variables and member functions from other functions and objects. Only functions of the same class can access its private members. Even an instance of a class cannot access its private members.Create a private variable −private double length;Let us see an example. Here, if we will try to access the length variable which is set private, then the following error would generate.BoxApplication.Box.length' is inaccessible due to its protection levelLet us see the complete example now −Exampleusing System; namespace BoxApplication { class Box { private double length; ... Read More

836 Views
The following are the tips −Prefer ListUse List whenever necessary. Working with ArrayList for the same work can make the working of code slower. This is specially if you are storing multiple types of objects within the same list.Use multiplication-shift operationPrefer multiplication-shift operation instead of division operator, since the usage of division operator slows the code.Less code takes less memoryTry to get work done using operator to concise the code and make it work in a single line.Use operators like && that would allow you to mention all the conditions in a single line.

228 Views
Operator functions are overloaded operator, which are the functions with special names. To create it, the keyword operator is followed by the symbol for the operator being defined.Like any other function, an overloaded operator has a return type and a parameter list.For example −public static Box operator+ (Vehicle v1, Vehicle v2, Vehicle v3) { }The following is the complete example showing how operator functions are created and used in C# −Exampleusing System; namespace OperatorOvlApplication { class Box { private double length; // Length of a box private double breadth; // Breadth of ... Read More

987 Views
A private constructor is used in classes containing only static member as shown below −class Demo { // private constructor private Demo() { } public static a = 10; }A singleton class has normal methods and you can call it using an instance.To prevent multiple instances of the class, the private constructor is used.Let us see an example −Examplepublic class Singleton { static Singleton a = null; private Singleton() { } }

1K+ Views
Private MethodsTo set private methods, use the private access specifier.Private access specifier allows a class to hide its member variables and member functions from other functions and objects. Only functions of the same class can access its private members. Even an instance of a class cannot access its private members.Final MethodsFor final methods, use the sealed modifier.When you use sealed modifiers in C# on a method, then the method loses its capabilities of overriding. The sealed method should be part of a derived class and the method must be an overridden method.Let us see an example −The following example won’t ... Read More