File tree 6 files changed +78
-0
lines changed
W3School-CSExercises/CS-Strings
6 files changed +78
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * from C# Strings: Exercise 1 ( https://www.w3schools.com/cs/exercise.asp?filename=exercise_strings1 )
3
+ *
4
+ * question:
5
+ * Fill in the missing part to create a greeting variable of type string and assign it the value Hello.
6
+ *
7
+ * ______ ________ = _______;
8
+ *
9
+ */
10
+ string greeting = "Hello" ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * from C# Strings: Exercise 2 ( https://www.w3schools.com/cs/exercise.asp?filename=exercise_strings2 )
3
+ *
4
+ * question:
5
+ * Use the correct operator to concatenate two strings:
6
+ *
7
+ * string firstName = "John ";
8
+ * string lastName = "Doe";
9
+ * string name = firstName _ lastName;
10
+ * Console.WriteLine(name);
11
+ *
12
+ */
13
+ string firstName = "John " ;
14
+ string lastName = "Doe" ;
15
+ string name = firstName + lastName ;
16
+ Console . WriteLine ( name ) ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * from C# Strings: Exercise 3 ( https://www.w3schools.com/cs/exercise.asp?filename=exercise_strings3 )
3
+ *
4
+ * question:
5
+ * Use the string interpolation method to concatenate two strings:
6
+ *
7
+ * string firstName = "John";
8
+ * string lastName = "Doe";
9
+ * string name = _"My full name is: ___________ __________";
10
+ * Console.WriteLine(name);
11
+ *
12
+ */
13
+ string firstName = "John" ;
14
+ string lastName = "Doe" ;
15
+ string name = $ "My full name is: { firstName } { lastName } ";
16
+ Console . WriteLine ( name ) ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * from C# Strings: Exercise 4 ( https://www.w3schools.com/cs/exercise.asp?filename=exercise_strings4 )
3
+ *
4
+ * question:
5
+ * Access the first character (H) in myString and print the result:
6
+ *
7
+ * string myString = "Hello";
8
+ * Console.WriteLine(___________);
9
+ *
10
+ */
11
+ string myString = "Hello" ;
12
+ Console . WriteLine ( myString [ 0 ] ) ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * from C# Strings: Exercise 5 ( https://www.w3schools.com/cs/exercise.asp?filename=exercise_strings5 )
3
+ *
4
+ * question:
5
+ * Use the correct property to print the length of the txt string.
6
+ *
7
+ * string txt = "Hello";
8
+ * Console.WriteLine(___.______);
9
+ *
10
+ */
11
+ string txt = "Hello" ;
12
+ Console . WriteLine ( txt . Length ) ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * from C# Strings: Exercise 6 ( https://www.w3schools.com/cs/exercise.asp?filename=exercise_strings6 )
3
+ *
4
+ * question:
5
+ * Use the correct method to output the value of the txt string to upper case letters.
6
+ *
7
+ * string txt = "Hello World";
8
+ * Console.WriteLine(txt._________);
9
+ *
10
+ */
11
+ string txt = "Hello World" ;
12
+ Console . WriteLine ( txt . ToUpper ( ) ) ;
You can’t perform that action at this time.
0 commit comments