Found 2745 Articles for Csharp

How to use Interface References in C#?

Jaisshree
Updated on 25-Apr-2023 17:26:22

328 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

LongLength property of an Array in C#

Jaisshree
Updated on 25-Apr-2023 17:23:07

183 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

How to set the alignment of Check Mark in CheckBox in C#?

Jaisshree
Updated on 25-Apr-2023 17:13:02

252 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

C# Program to Read the Content of a File Line by Line

Ankit kumar
Updated on 21-Apr-2023 14:37:49

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

C# Program to Get the relative path from two absolute paths

Ankit kumar
Updated on 21-Apr-2023 14:36:44

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

C# Program to get the name of the file from the absolute path

Ankit kumar
Updated on 21-Apr-2023 14:33:44

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

C# Program to Get and Print the Command Line Arguments Using Environment Class

Ankit kumar
Updated on 21-Apr-2023 14:31:23

202 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

C# Program to Get all Files Present in a Directory

Ankit kumar
Updated on 21-Apr-2023 14:30:04

9K+ Views

Introduction On the computer, we can store files in a directory, also known as a folder. A directory also contains shortcuts to other directories and files. If we want to know what all files have stored in a directory then C# also offers an easy way to do so. In this article, we will be learning a C# program to get all files present in a directory. There are more than a couple of ways to know the files available in the directory. Let us discuss them in the upcoming sections. 1. GetFiles() Method For knowing the name ... Read More

C# Program to Generate Marksheet of Student

Ankit kumar
Updated on 21-Apr-2023 14:27:37

3K+ Views

Introduction There are a lot of ways to generate a mark sheet for a student. Today we will learn one of them. In this article, we will learn a C# program to generate the mark sheet of a student. Let us learn the algorithm first. Algorithm Let us discuss the algorithm to write the program which generates the mark sheet of a student. The student has to give the input to the system and then the mark sheet is generated. Step 1 − Firstly we declare the integer variables for storing the different data such as the roll ... Read More

C# Program to find the greatest number in an array using the WHERE clause LINQ

Ankit kumar
Updated on 21-Apr-2023 14:25:55

193 Views

Introduction In this article, we are going to find the greatest number in an array using the WHERE clause in LINQ. LINQ (Language Integrated query) is used to generate queries in C# Language. The best part of LINQ is that it provides a unified source of the method to access data from different sources like databases and XML documents. With the help of LINQ, users can write code that has much better readability and the code is much more concise and good-looking. It also provides other functionalities like filtering, sorting, grouping data and even changing them. Before moving ahead we ... Read More

Previous 1 ... 3 4 5 6 7 ... 275 Next
Advertisements