The #undef directive allows you to undefine a symbol. The following is the syntax −#undef SYMBOLFor example,#undef OneIt evaluates to false when used along with #if directive. Let us see an example −Example Live Demo#define One #undef Two using System; namespace Demo { class Program { static void Main(string[] args) { #if (One && TWO) Console.WriteLine("Both are defined"); #elif (ONE && !TWO) Console.WriteLine("ONE is defined and TWO is undefined"); #elif (!ONE && TWO) Console.WriteLine("ONE is defined and TWO is undefined"); #else Console.WriteLine("Both are undefined"); #endif } } }OutputBoth are undefined
It handles errors generated from referencing a null object. The Null reference exception occurs when you are looking to access member fields or function types that points to null.Let’s say we have the following null string −string str = null;Now you try to get the length of the null string, then it would cause an exception −If(str.Length == null) {}Above the exception will be thrown. Now let us seen how to prevent the null pointer exception to be thrown −Example Live Demousing System; class Program { static void Main() { int[] arr = new int[5] {1, ... Read More
IS operatorThe "is" operator in C# checks whether the run-time type of an object is compatible with a given type or not.The following is the syntax −expr is typeHere, expr is the expressiontype is the name of the typeThe following is an example showing the usage of is operator in C# &minis;Example Live Demousing System; class One { } class Two { } public class Demo { public static void Test(object obj) { One x; Two y; if (obj is One) { Console.WriteLine("Class One"); ... Read More
C# is a modern, general-purpose, object-oriented programming language developed by Microsoft. C# is designed for Common Language Infrastructure (CLI), which consists of the executable code and runtime environment that allows the use of various high-level languages on different computer platforms and architectures.The following are the major features of C# −Following is the list of few important features of C# −Boolean ConditionsAutomatic Garbage CollectionStandard LibraryAssembly VersioningProperties and EventsDelegates and Events ManagementEasy-to-use GenericsIndexersConditional CompilationSimple MultithreadingLINQ and Lambda ExpressionsIntegration with Windows
Polymorphism can be static or dynamic. In static polymorphism, the response to a function is determined at the compile time. In dynamic polymorphism, it is decided at run-time.Compile Time Polymorphism or Static BindingThe mechanism of linking a function with an object during compile time is called early binding. It is also called static binding or early binding.Run Time Polymorphism or Dynamic BindingRuntime polymorphism has method overriding that is also known as dynamic binding or late binding.Abstract classes contain abstract methods, which are implemented by the derived class. The derived classes have more specialized functionality. Dynamic polymorphism is implemented by abstract classes and virtual functions.Read More
The C# static class cannot be instantiated and can only have only static members. The static class in C# is sealed and cannot contain instance constructors.The following is an example with static class and static members −Example Live Demousing System; public static class Demo { public static float PI = 3.14f; public static int calc(int n){return n*n;} } class Program { public static void Main(string[] args) { Console.WriteLine("PI: "+Demo.PI); Console.WriteLine("Square: " + Demo.calc(3)); } }OutputPI: 3.14 Square: 9Above, the static class is −public static class Demo { ... Read More
Use the translateX(n) method to transform the element along with x-axis.Let us see the syntaxtranslateX(n)Here, n is a length representing the abscissa of the translating vector.Let us see an examplediv { width: 50px; height: 50px; background-color: black; } .trans { transform: translateX(20px); background-color: orange; }
The multi-column rule-style property is used to specify the style rule for the column. You can try to run the following code to implement rule-style property using CSS −ExampleLive Demo .multi { /* Column count property */ -webkit-column-count: 4; -moz-column-count: 4; column-count: 4; /* Column gap property */ ... Read More
A pointer is a variable whose value is the address of another variable i.e., the direct address of the memory location. Similar to any variable or constant, you must declare a pointer before you can use it to store any variable address.The syntax of a pointer is −type *var-name;The following is how you can declare a pointer type −int *ip; /* pointer to an integer */ double *dp; /* pointer to a double */C# allows using pointer variables in a function of code block when it is marked by the unsafe modifier. The unsafe code or the unmanaged code is ... Read More
We can define class members as static using the static keyword. When we declare a member of a class as static, it means no matter how many objects of the class are created, there is only one copy of the static member.The keyword static implies that only one instance of the member exists for a class. Static variables are used for defining constants because their values can be retrieved by invoking the class without creating an instance of it.The following is an example showing the usage of static variables −Example Live Demousing System; namespace StaticVarApplication { class StaticVar { ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP