Programming Articles

Page 812 of 2547

How to define a single-dimensional array in C Sharp?

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 366 Views

An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type stored at contiguous memory locations. A single-dimensional array in C# is a linear collection of elements of the same data type. It allows you to store multiple values in a single variable and access them using an index. Syntax Following is the syntax for declaring a single-dimensional array − datatype[] arrayName = new datatype[size]; Following is the syntax for initializing an array with ...

Read More

Networking in C#

George John
George John
Updated on 17-Mar-2026 3K+ Views

The .NET Framework provides a layered, extensible, and managed implementation of networking services that you can easily integrate into your applications. The System.Net namespace contains classes for network communication, web requests, DNS operations, and secure connections. Syntax To use networking classes, include the System.Net namespace − using System.Net; Creating a URI and web request − Uri uri = new Uri("http://www.example.com/"); WebRequest request = WebRequest.Create(uri); Using Uri Class The Uri class in C# provides object representation of a uniform resource identifier (URI). It helps parse and manipulate web addresses − ...

Read More

C# Program to display the number of days in a month

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 807 Views

The DateTime.DaysInMonth() method in C# is used to display the number of days in a specific month and year. This static method is particularly useful when working with calendar calculations or when you need to validate dates. Syntax Following is the syntax for using DateTime.DaysInMonth() − int days = DateTime.DaysInMonth(year, month); Parameters year: An integer representing the year (1 to 9999). month: An integer representing the month (1 to 12). Return Value Returns an integer representing the number of days in the specified month and ...

Read More

C# Program to find a key in a Hashtable

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 519 Views

A Hashtable in C# is a collection of key-value pairs where each key is unique. To check if a specific key exists in a Hashtable, you can use the Contains() method or ContainsKey() method. Syntax Following is the syntax for creating a Hashtable and checking if a key exists − Hashtable hashtable = new Hashtable(); hashtable.Add(key, value); bool exists = hashtable.Contains(key); Alternatively, you can use ContainsKey() method − bool exists = hashtable.ContainsKey(key); Using Contains() Method The Contains() method returns true if the specified key exists in the Hashtable, otherwise ...

Read More

Byte.MinValue Field in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 164 Views

The Byte.MinValue field in C# represents the smallest possible value that a byte data type can hold. Since byte is an unsigned 8-bit integer, its minimum value is always 0. Syntax Following is the syntax for accessing the Byte.MinValue field − public const byte MinValue = 0; The field is accessed as − byte minValue = Byte.MinValue; Understanding Byte Range The byte data type in C# is an unsigned 8-bit integer that can store values from 0 to 255. The Byte.MinValue constant provides the lower bound of this range. ...

Read More

Abstract vs Sealed Classes vs Class Members in C#

karthikeya Boyini
karthikeya Boyini
Updated on 17-Mar-2026 2K+ Views

The abstract class includes abstract and non-abstract methods. You cannot instantiate an abstract class directly. The sealed class prevents inheritance and you cannot use it as a base class. Both abstract and sealed classes can contain various types of class members with different access modifiers and behaviors. Abstract Classes To declare an abstract class, you need to place the keyword abstract before the class definition. An abstract class can contain abstract methods that must be implemented by derived classes − Syntax public abstract class ClassName { public abstract void MethodName(); ...

Read More

What are file operations in C#?

Ankith Reddy
Ankith Reddy
Updated on 17-Mar-2026 505 Views

File operations in C# allow you to work with files and directories on the file system. These operations include creating, opening, reading, writing, appending, and deleting files. The System.IO namespace provides comprehensive classes and methods for file handling. The FileStream class is the primary class for file operations in C#. It provides low-level access to files and derives from the abstract Stream class. This class enables reading from, writing to, and closing files efficiently. Syntax To create a FileStream object, use the following syntax − FileStream fileStream = new FileStream(fileName, FileMode, FileAccess, FileShare); ...

Read More

TimeSpan.From methods in C# ()

Chandu yadav
Chandu yadav
Updated on 17-Mar-2026 225 Views

The TimeSpan.From methods in C# provide a convenient way to create TimeSpan objects from specific time units. These static methods include FromDays, FromHours, FromMinutes, FromSeconds, FromMilliseconds, and FromTicks. Each method takes a numeric value and returns a TimeSpan representing that duration in the specified unit. This approach is more readable than manually calculating ticks or using TimeSpan constructors. Syntax Following are the syntax formats for the most commonly used TimeSpan.From methods − TimeSpan.FromDays(double value) TimeSpan.FromHours(double value) TimeSpan.FromMinutes(double value) TimeSpan.FromSeconds(double value) TimeSpan.FromMilliseconds(double value) TimeSpan.FromTicks(long value) Parameters All TimeSpan.From methods (except FromTicks) accept a ...

Read More

What are Booleans types in C#?

Arjun Thakur
Arjun Thakur
Updated on 17-Mar-2026 227 Views

The bool type in C# represents Boolean values and can store only two possible values: true and false. The bool keyword is an alias for the System.Boolean structure in the .NET framework. Boolean variables are commonly used in conditional statements, loops, and logical operations to control program flow based on true/false conditions. Syntax Following is the syntax for declaring Boolean variables − bool variableName = true; // or false bool variableName; // defaults to false Basic Boolean Declaration and Assignment Example ...

Read More

Byte.ToString() Method in C#

AmitDiwan
AmitDiwan
Updated on 17-Mar-2026 114 Views

The Byte.ToString() method in C# converts the value of the current Byte object to its equivalent string representation. This method is inherited from the Object class and overridden to provide byte-specific string conversion. Syntax Following is the syntax for the basic ToString() method − public override string ToString(); The Byte class also provides overloaded versions that accept format specifiers − public string ToString(string format); public string ToString(IFormatProvider provider); public string ToString(string format, IFormatProvider provider); Using Basic ToString() Method The parameterless ToString() method converts a byte value to its decimal ...

Read More
Showing 8111–8120 of 25,466 articles
« Prev 1 810 811 812 813 814 2547 Next »
Advertisements