The difference between is and as operators are as follows: The is operator is used to check if the run-time type of an object is compatible with the given type or not whereas as operator is used to perform conversion between compatible reference types or Nullable types.
Every Question..What does it mean? Why is this? How it works?
Microsoft .Net (pronounced dot (.) net) may be a package element that runs on the Windows software package.
.Net provides tools and libraries that change developers to form Windows package a lot of quicker and easier.
Microsoft describes it as:".Net is that the Microsoft internet Service strategy to attach data, people,
system and devices through software".I'm Choulla Naresh..!
Wednesday, August 26, 2020
What is difference between generic and non generic in C#?
A Generic collection is a class that provides type safety without having to derive from a base collection type and implement type-specific members. The key difference between Generic and Non-generic Collection in C# is that a Generic Collection is strongly typed while a Non-Generic Collection is not strongly typed.
What is generic list in C#?
In c#, List is a generic type of collection so it will allow storing only strongly typed objects i.e. elements of the same data type, and the size of the list will vary dynamically based on our application requirements like adding or removing elements from the list.
Can we store different types in an array in C#?
In c# we use an object[] array to store different types of data in each element location. You can use an object[] (an object array), but it would be more flexible to use List<object>. It satisfies your requirement that any kind of object can be added to it, and like an array, it can be accessed through a numeric index.
List vs array in C#
Arrays are strongly typed which means it can store only specific type of items or elements. Arraylist are not strongly typed. Array cannot accept null. ArrayList can accepts null.
What are circular references in C#?
A circular reference occurs when two or more interdependent resources cause lock condition. This makes the resource unusable.
To handle the problem of circular references in C#, you should use garbage collection. It detects and collects circular references. The garbage collector begins with local and static and it marks each object that can be reached through their children.
Through this, you can handle the issues with circular references.
Let’s say the following classes are in a circular reference. Here both of them depends on each other
public class Hyd {
Wgl Two;
}
public class Wgl {
Hyd one;
}
to solve this issue using interfaces
public interface ourInterface {
}
public class Hyd{
ourInterface Two;
}
public class Wgl: myInterface {
Hyd one;
}
Monday, August 24, 2020
What is IDisposable in C#?
IDisposable is an interface that contains a single method, Dispose of (), for releasing unmanaged resources, like files, streams, database connections, and so on.
Can we have 2 main methods in C#?
In a C# application, we can have multiple Main methods but only one of them with valid Main signature can be treated as Startup or Entry Point of the application.
Why main method is static in C#?
The Main method states what the class does when executed and instantiates other objects and variables. The main method is static since it is available to run when the C# program starts. It is the entry point of the program and runs without even creating an instance of the class.
What is the static keyword in C#?
In C# terms, “static” means “relating to the type itself, rather than an instance of the type”. You access a static member using the type name instead of a reference or a value, e.g. Guid. NewGuid(). In addition to methods and variables, you can also declare a class to be static (since C# 2.0).