.NET API Reference
String Class
public sealed class String
Represents text as a sequence of code points.
Summary
The String class represents a string of characters. Strings are immutable, meaning that once a String object is created, its value cannot be changed. However, because String objects are immutable, operations that appear to modify them actually create new String objects that contain the modified versions.
Constructors
String(Char[], Int32, Int32)
public String(char[] value, int startIndex, int count)
Initializes a new instance of the String class by concatenating elements of a character array.
Parameters
A character array containing the characters to be converted to a string.
The starting position of the substring to use.
The number of characters to use.
Methods
IsNullOrEmpty(String)
public static bool IsNullOrEmpty(string value)
Indicates whether the specified string is null or an empty string ("").
Parameters
The string to test.
Return Value
true
if the value
parameter is null or an empty string (""); otherwise, false
.Example
string myString = ""; if (String.IsNullOrEmpty(myString)) { Console.WriteLine("The string is null or empty."); }
Replace(Char, Char)
public string Replace(char oldChar, char newChar)
Returns a new string in which all occurrences of a specified Unicode character in this instance are replaced with another specified Unicode character.
Parameters
The character to replace.
The character that replaces
oldChar
.Return Value
A new string that is equivalent to this string but with all instances of
oldChar
replaced by newChar
.Example
string original = "hello world"; string replaced = original.Replace('l', 'X'); Console.WriteLine(replaced); // Output: heXXo worXd
List<T> Class
public class List<T>
Represents a strongly typed list of objects that can be accessed by index. Provides methods for creating, searching and manipulating lists.
Summary
The List(T) generic type is a user-defined collection that allows for fast insertion and retrieval of elements. It is a generic type, meaning that it can store any type of data. The List(T) class is a part of the System.Collections.Generic namespace.
Methods
Add(T)
public void Add(T item)
Appends the given element to the end of the List(T).
Parameters
The object to be added to the end of the List(T). The value can be null for reference types.
File Class
public static class File
Provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of FileStream objects.
Methods
ReadAllText(String)
public static string ReadAllText(string path)
Opens a text file, reads all lines of the file, and then closes the file.
Parameters
The file to open. The file must exist.
Return Value
A string containing all of the lines of the file.
ControllerBase Class
public abstract class ControllerBase
A base class for controllers that handle incoming requests.
Properties
ControllerContext
public ControllerContext ControllerContext { get; }
Gets or sets the controller context.
ModelState
public ModelStateDictionary ModelState { get; }
Gets a dictionary that contains the model state.