-
Notifications
You must be signed in to change notification settings - Fork 0
/
stringlowercase2.cs
50 lines (30 loc) · 1.13 KB
/
stringlowercase2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// The error after compilation , "Property or indexer 'string.this[int]' cannot be assigned to -- it is read-only," is because we're trying to modify a character in
//a string directly, which is not allowed because strings in C# are immutable (cannot be changed).
// this code was written for practice of making upper case to lower case without inbuild function.
using System;
namespace stringUpper
{
class stringuppercase1
{
static void Main(string[] args)
{
Console.WriteLine("Enter you first name in uppercase : ");
string name = Console.ReadLine();
Console.WriteLine("your name is " +name);
int a = 0;
while(name[a] != '\0')
{
if(name[a] >= 65 && name[a] <= 90)
{
name[a] = (char)(name[a] + 32);
a++;
}
else
{
a++;
}
}
Console.WriteLine(name);
}
}
}