Ankith Reddy has Published 996 Articles

What are finalizers in C#?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 17:09:55

1K+ Views

Finalizers in C# are used to destruct instances of classes. With that, you can also use it to release resources.Here are some of the key points about Finalizers −Only one finalizer is allowed for a classYou cannot inherit or overload FinalizersA finalizer cannot have parametersFinalizers invoke automaticallyFinalizers in C# are ... Read More

What are object data types in C#?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 17:00:10

956 Views

The object types can be assigned values of any other types, value types, reference types, predefined or user-defined types. However, before assigning values, it needs type conversion.The Object Type is the ultimate base class for all data types in C# Common Type System (CTS). Object is an alias for System.Object ... Read More

What are nested namespaces in C#?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 16:58:33

2K+ Views

A namespace inside a namespace is called a nested namespace in C#. This is mainly done to properly structure your code.We have an outer namespace −namespace outer {}Within that, we have an inner namespace inside the outer namespace −namespace inner {    public class innerClass {       public ... Read More

What are file operations in C#?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 16:44:13

387 Views

C# has the following file operations −Create, open, read and write a file.Append, Delete, etc.The FileStream class in the System.IO namespace helps in reading from, writing to and closing files. This class derives from the abstract class Stream.You need to create a FileStream object to create a new file or ... Read More

What are generic collections in C#?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 16:42:29

724 Views

Generic collections in C# include , , etc.ListList is a generic collection and the ArrayList is a non-generic collection.Let us see an example. Here, we have six elements in the list −Example Live Demousing System; using System.Collections.Generic; class Program {    static void Main() {       ... Read More

What is String Title case in C#?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 16:31:55

2K+ Views

The ToTitleCase method is used to capitalize the first letter in a word. Title case itself means to capitalize the first letter of each major word.Let us see an example to get the title case −Example Live Demousing System; using System.Globalization; class Demo {    static void Main() {   ... Read More

What are circular references in C#?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 16:30:28

3K+ Views

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 ... Read More

What are floating point literals in C#?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 16:27:44

1K+ Views

A floating-point literal has an integer part, a decimal point, a fractional part, and an exponent part. You can represent floating point literals either in decimal form or exponential form.The following are some of the examples of floating point literals −9.23456 269485E-5FLet us now print the floating point literals −Example Live ... Read More

How to capture out of memory exception in C#?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 16:08:22

2K+ Views

The System.OutOfMemoryException occurs when the CLR fail in allocating enough memory that is needed.System.OutOfMemoryException is inherited from the System.SystemException class.Set the strings −string StudentName = "Tom"; string StudentSubject = "Maths";Now you need to initialize with allocated Capacity that is the length of initial value −StringBuilder sBuilder = new StringBuilder(StudentName.Length, StudentName.Length);Now, ... Read More

What are the different ways for a method to be overloaded in C#?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 16:04:34

226 Views

The different ways with which a method can be overloaded is −The datatypes of parameters are different The number of parameters are differentThe following gives an example stating different datatypes of parameters −void print(int i) {    Console.WriteLine("Printing int: {0}", i ); } void print(double f) {    Console.WriteLine("Printing ... Read More

Advertisements