Skip to content

Sablesync/String-for-C-

Repository files navigation

Guide: Filling in the Question Marks with Variables and run it after ever update

Introduction

This guide will walk you through filling in the question marks with variables in the provided code. By following the instructions below, you will learn how to use variables and various string methods in C#.

Step 1: Printing a Simple String

  1. Uncomment the following line of code:
    // Console.WriteLine(?); // simple print using console
  2. Replace the question mark with a string variable of your choice.
  3. Run the program to see the output.

Step 2: Finding the Length of a String

  1. Uncomment the following line of code:
    // Console.WriteLine(?); // finds the number of characters in a string using .Length
  2. Replace the question mark with a string variable of your choice.
  3. Run the program to see the output.

Step 3: String Interpolation

  1. Uncomment the following line of code:
    // Console.WriteLine(?); // string interpolation e.g Console.WriteLine($"The name Azhar has {myname.Length} characters"); // string interpolation
  2. Replace the question mark with a string variable of your choice.
  3. Run the program to see the output.

Step 4: Trimming Spaces from a String

  1. Uncomment the following line of code:
    // string newName = yourname.Trim(); // you can trim the spaces of a string using .Trim() method e.g Console.WriteLine(yourname.Trim()); // you can also print out your new trim as a variable newName
  2. Replace the question marks with a string variable and a new variable name of your choice.
  3. Run the program to see the output.

Step 5: Changing a String to Uppercase

  1. Uncomment the following line of code:
    // string ? = ?.ToUpper(); // use .ToUpper() to change a string to uppercase
  2. Replace the question marks with a string variable of your choice.
  3. Run the program to see the output.

Step 6: String Replacement

  1. Uncomment the following line of code:
    // string newSentencepractice = sentencepractice.Replace("?", "?"); // try out the replace method and see what it does
  2. Replace the question marks with a string variable and a new variable name of your choice.
  3. Run the program to see the output.

Step 7: More Practice with String Methods

  1. Uncomment the following line of code:
    // Console.WriteLine(?.Length); // more practice with string methods
  2. Replace the question mark with a string variable of your choice.
  3. Run the program to see the output.

Step 8: Creating a New String Variable

  1. Uncomment the following line of code:
    // Console.WriteLine(?.Replace("?", "?"));
    // Console.WriteLine(?.ToUpper());
  2. Replace the question marks with a new string variable and a value of your choice.
  3. Run the program to see the output.

Step 9: Sample Program Utilizing All Concepts

  1. Uncomment the following lines of code:
    // Sample program utilizing all the concepts.
    // Console.WriteLine("Azhar     "); // simple print
    // string myName = "Azhar";
    // Console.Write($"My name is {myName.TrimEnd()} and it has {myName.Length} characters. Jokes it is Actually 5 Characters.");
    // Console.WriteLine($" It can also be written in uppercase like this {myname.Trim().ToUpper()} and now I will share a bit about my history");
    // string history = $"As I said my name is {myname.Trim()} and it is made up of {myname.Length} letters. {newSentencepractice.Replace("My name is", "My job description is")}";
    // Console.WriteLine(history);
  2. Replace the question marks with appropriate string variables and values of your choice.
  3. Run the program to see the output.

Step 10: Introduction to Booleans

  1. Uncomment the following lines of code:
    // Remove the "/*" and "*/" to activate the program below
    
    /* if(?.StartsWith("a") == true) { // we will use this program to test out the StartsWith method
         Console.WriteLine("yey");
    } else if (myName.StartsWith("Ahar") == true) {
         Console.Write("I would have never known");
    } else {
         Console.WriteLine(false);
    }
    
    var ? = ?.ToCharArray();
    Console.WriteLine(?.Reverse());
    
    if (?.EndsWith("R") == true) {
         Console.Write("hmm, are you a genius");
    } else if (?.EndsWith("ar") == false) {
         Console.WriteLine("ha, got em");
    } else {
         Console.WriteLine("I think soon we will get the hang of this if we keep experimenting");
    }
  2. Replace the question marks with appropriate string variables and values of your choice.
  3. Run the program to see the output.

Congratulations! You have successfully filled in the question marks with variables based on the provided code. Keep experimenting and exploring different concepts to enhance your programming skills.

About

Understanding string methods and properties

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages