Found 34494 Articles for Programming

What is a base class in C#?

karthikeya Boyini
Updated on 20-Jun-2020 17:35:47

1K+ Views

When creating a class, instead of writing completely new data members and member functions, the programmer can designate that the new class should inherit the members of an existing class. This existing class is called the base class, and the new class is referred to as the derived class.A class can be derived from more than one class or interface, which means that it can inherit data and functions from multiple base classes or interfaces.The following is the syntax of base class in C# − class {    ... } class : {    ... }Let ... Read More

What is the C# Equivalent of SQL Server DataTypes?

Chandu yadav
Updated on 20-Jun-2020 17:18:20

13K+ Views

The following table displays the C# equivalent of SQL Server datatypes −SQL Server data typeEquivalent C# data typevarbinaryByte[]binaryByte[]imageNonevarcharNonecharNonenvarcharString, Char[]ncharString, Char[]textNonentextNonerowversionByte[]bitBooleantinyintBytesmallintInt16intInt32bigintInt64smallmoneyDecimalmoneyDecimalnumericDecimaldecimalDecimalrealSinglefloatDoublesmalldatetimeDateTimedatetimeDateTimetableNonecursorNonetimestampNonexmlNone

Try/catch/finally/throw keywords in C#

karthikeya Boyini
Updated on 20-Jun-2020 17:20:08

2K+ Views

Exception handling is based on the following keywords and its usage −try − A try block identifies a block of code for which particular exceptions is activated. It is followed by one or more catch blocks.catch − A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception.finally − The finally block is used to execute a given set of statements, whether an exception is thrown or not thrown. For example, if you open a file, it must be closed ... Read More

What is the best IDE for C# on MacOS?

George John
Updated on 20-Jun-2020 17:20:26

738 Views

On Windows, the best IDE to run C# programs is Visual Studio. On MacOS, the best IDE can be considered as Monodevelop.Monodevelop is an open source IDE that allows you to run C# on multiple platforms i.e. Windows, Linux and MacOS. Monodevelop is also known as Xamarin Studio.Monodevelop has a C# compiler to run C# programs. It can be used on Windows, macOS and Linux.For Mac, a special version of MonoDevelop was introduced and it was called Visual Studio for Mac. It has many of the features of what the same IDE provides for Windows like tool for and IntelliSense ... Read More

Streams In C#

Ankith Reddy
Updated on 20-Jun-2020 17:21:47

5K+ Views

The stream is basically the sequence of bytes passing through the communication path. There are two main streams: the input stream and the output stream. The input stream is used for reading data from file (read operation) and the output stream is used for writing into the file (write operation).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.Create a FileStream object to create a new file or open an existing file. The following is the syntax −FileStream = new FileStream( , , , );Here, ... Read More

Substring in C#

karthikeya Boyini
Updated on 20-Jun-2020 17:24:37

465 Views

Substring is used to get the sub-parts of a string in C#. We have the substring() method for this purpose. Use the substring() method in C# to check each and every substring for unique characters. Loop it until the length of the string.If anyone the substring matches another, then it would mean that the string does not have unique characters.You can try to run the following code to determine if a string has all unique characters. The example shows the usage of Substring() method −Exampleusing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; public class Demo { ... Read More

Try-Catch-Finally in C#

Samual Sam
Updated on 20-Jun-2020 17:26:18

6K+ Views

C# exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero.C# exception handling is performed using the following keywords −try − A try block identifies a block of code for which particular exceptions is activated. It is followed by one or more catch blocks.catch − A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception.finally − The finally block is used to execute a given set ... Read More

What is the base class for all exceptions in C#?

Arjun Thakur
Updated on 20-Jun-2020 17:26:45

1K+ Views

The System.SystemException class is the base class for all predefined system exception. Some of the exception classes derived from the System.Exception class are the System.ApplicationException and System.SystemException classes.The System.ApplicationException class supports exceptions generated by application programs. Hence the exceptions defined by the programmers should derive from this class.The following are the exceptions under the base class System.SystemException −Sr.No.Exception Class & Description1System.IO.IOExceptionHandles I/O errors.2System.IndexOutOfRangeExceptionHandles errors generated when a method refers to an array index out of range.3System.ArrayTypeMismatchExceptionHandles errors generated when type is mismatched with the array type.4System.NullReferenceExceptionHandles errors generated from referencing a null object.5System.DivideByZeroExceptionHandles errors generated from dividing a dividend with zero.6System.InvalidCastExceptionHandles errors ... Read More

What are reference data types in C#?

Chandu yadav
Updated on 20-Jun-2020 17:06:41

1K+ Views

The reference data type in C# does not have the actual data stored in a variable, but they contain a reference to the variables.In C#, the following are the built-in reference types −Object TypeThe Object Type is the ultimate base class for all data types in C# Common Type System (CTS). The object types can be assigned values of any other types, value types, reference types, predefined or user-defined types.Exampleobject ob; ob = 250; // boxingDynamic TypeStore any type of value in the dynamic data type variable. Type checking for these types of variables takes place at run-time.Exampledynamic d = ... Read More

What are finalizers in C#?

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

668 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 declared like destructors. Let’s say the class name is Demo, therefore, the following would be our finalizer −~Demo() {    // }The finalizer declaration is prefixed with a tilde before the class name.

Advertisements