3. C# - Strings

 String Length Method:

stringVariable.Length; // returns length of string


String Substring Method:

stringVariable.Substring(minRange, maxRange);

// returns the given substring between those two index ranges


String Equals Method:

stringVariable.Equals(stringVariableToCompare);

// returns true or false if they equal


String Split Method:

// this method splits a string and places the results into an string array

string [] separators = {"," , ":"}; // creates an array that list what the separators are contained in quotations and separated by commas.

string [] names = {"PETER, JOHN; ANDY, , DAVID"};

string [] results = names.Split(separators, StringSplitOptions.None); // this creates an array to hold the results. parameters are the separators and the split option with method none.

// change the method from None to RemoveEmptyEntries will skip empty results.


Convert Method:

int variable = Convert.ToInt32(variableBefore);

decimal variable = Convert.ToDecimal(variableBefore);

char variable = Convert.ToSingle(variableBefore);

double variable = Convert.ToDouble(variableBefore);


Comments

Popular posts from this blog

20. Data Analytics - Analyze Data to Answer Questions - Week 1

2. FreeCodeCamp - Dynamic Programming - Learn to Solve Algorithmic Problems & Coding Challenges

5. SQL Injection - Blind SQL Injection