
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 2587 Articles for Csharp

7K+ Views
C# is a powerful object-oriented programming language used for developing a wide range of applications. In this article, we will discuss how to write a C# program to read and write a byte array to a file using the FileStream class. Step 1: Creating a Byte Array The first step in this program is to create a byte array that we want to write to a file. Here is an example − byte[] byteArray = { 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64 }; Step 2: Writing Byte Array to File The next step is ... Read More

411 Views
Is operator also called as the type-compatibility operator plays an integral role in C# structures. Let’s try to understand this operator. C#’s Is operator checks if the given object is compatible with another object and gives the result as true, if it is compatible. Else returns false. Syntax expression is obj Example Expression is the object which you like to check compatibility with. The expression can include variables, literals and method calls. Obj is the type against which the expression is verified. This can comprise of built-in and user-defined types. // The operation of the type compatibility operator is ... Read More

2K+ Views
A BitArray is a collection of Boolean values represented as a series of 1’s and 0’s. It is often used to store and manipulate binary data efficiently. In C#, the BitArray class is part of the System. Collections namespace, and it allows you to manipulate the individual bits in the array using bitwise operators. Inverting all bit Values in a BitArray To invert all bit values in a BitArray in C#, you can use the exclusive OR (XOR) operator (^) with the number 1. This operator returns a value of 1 if the bits being compared are different and 0 ... Read More

804 Views
C# is an object-oriented programming language that offers a unique feature known as interfaces. They enable you to declare a collection of attributes and methods that a class must implement without mentioning the specifics of how they should be implemented. The ability to write code that is independent of a class's implementation details is one of the main benefits of interfaces. Each object of any class that implements the interface can be referred to using an interface reference. As a result, it is simpler to switch between different class implementations without having to modify the code that utilizes the class. ... Read More

561 Views
In C#, the Array class has a read-only property called LongLength. It returns a long integer value that indicates how many elements the array can accommodate. Only arrays with a rank of one or more, i.e., those that are not single-dimensional arrays, can access the LongLength property. Although the LongLength property provides a long integer value, it's crucial to remember that the maximum size of an array in C# is still constrained by the amount of memory that the system supports. If you try to build an array that is too big, an OutOfMemoryException can be raised. Syntax public long ... Read More

518 Views
In a graphical user interface, a CheckBox control in C# enables users to pick a true/false or yes/no choice. The check mark in a CheckBox control is normally aligned to the left, but there are instances when you would wish to move it to the center or right. Alignment of the Check Mark in a CheckBox TextAlign Property To set the alignment of the check mark in a CheckBox control, you need to use the TextAlign property. The TextAlign property is an enumeration that allows you to set the horizontal alignment of the text and check mark within the control.Syntax ... Read More

18K+ Views
Introduction Here, we’ll be learning to write a C# program to Read the content of a file content line by line. There are various methods to do so. We will be discussing them one by one. File handling is done in C#. In most cases, the file is used to store data. File handling or file management in layman’s terms the various processes such as making the file, reading from it, writing to it, appending it, and so on. The reading and writing of files are the two most common operations in file handling. 1. Using File.ReadLines() method ... Read More

6K+ Views
Introduction Let us try to understand the C# program to get the relative path from two absolute paths. We will understand using the URI( Uniform resource identifier) class and the MakeRelativeUri method. We will first understand the difference between absolute and relative paths. The absolute path includes all information required to locate a file or directory on a system. An example of an absolute path is C:\Program Files\Google Chrome\filename.exe. The relative path tells us the file's path with respect to the current directory on which the user is working. Considering the similar example mentioned above if the main executable ... Read More

3K+ Views
Introduction Let us try to understand the C# program to get the name of the file from the absolute path. We will see the usage of the GetFileName method which comes under the File class to get the name of the file, and another method GetFileNameWithoutExtension which will return the file name of the specified path string without extension. To get the relative path from two absolute paths, we will make use of the Uri class in C#. The Uri class provides several methods for working with URIs, including MakeRelativeUri, which we will use in our code. A file is ... Read More

358 Views
Introduction Let us see how to use the instrumental environment class of C# to write a C# Program to Get and Print the Command Line Arguments Using Environment Class. Knowing all the things about C#, we will now understand one of the uses of the system.environment class in C# and then we will learn to code a program that will get and print the command line arguments. Basically, it will take strings as arguments and will have its return type as a string. Before diving into the program we must have an overview of what is environment class in detail ... Read More