Ankith Reddy has Published 1070 Articles

What are object data types in C#?

Ankith Reddy

Ankith Reddy

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

631 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

1K+ 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

217 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

526 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

793 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

1K+ 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

160 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

What is a Ternary operator/conditional operator in C#?

Ankith Reddy

Ankith Reddy

Updated on 20-Jun-2020 15:55:02

256 Views

Ternary operator is a Conditional operator in C#. It takes three arguments and evaluates a Boolean expression.For example −y = (x == 1) ? 70 : 100;Above, if the first operand evaluates to true (1), the second operand is evaluated. If the first operand evaluates to false (0), the third ... Read More

Advertisements