https://www.youtube.com/watch?v=ovmC_58wsNY&list=PLO56HZSjrPTB4NxAsEP8HRk6YKBDLbp7m&index=44
string message = "hello world";
using System;
using static System.Console;
namespace testProject
{
class Program
{
static void Main(string[] args)
{
string message = "hello world";
WriteLine(message.ToUpper());
WriteLine(message.ToLower());
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
static void Main(string[] args)
{
string message = "hello world";
WriteLine(message.Replace("hello", "hi"));
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
static void Main(string[] args)
{
string message = "hello world";
WriteLine(message.Length);
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
static void Main(string[] args)
{
string message = " hello world ";
WriteLine(message);
WriteLine(message.Trim());
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
static void Main(string[] args)
{
string message = "hello world";
WriteLine(message.Contains("hello"));
WriteLine(message.Contains("hi"));
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
static void Main(string[] args)
{
string message = "hello world";
WriteLine(message.StartsWith("hello"));
WriteLine(message.StartsWith("hi"));
WriteLine(message.EndsWith('d'));
WriteLine(message.EndsWith('k'));
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
static void Main(string[] args)
{
string DbUserName = "Kain";
string InputUserName = "kain";
WriteLine(DbUserName == InputUserName);
WriteLine(DbUserName.ToLower() == InputUserName.ToLower());
WriteLine(DbUserName.Equals(InputUserName));
// StringComparison.InvariantCultureIgnoreCase
// 대소문자 구별 안하는 옵션
WriteLine(DbUserName.Equals(InputUserName, StringComparison.InvariantCultureIgnoreCase));
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
static void Main(string[] args)
{
string message1 = "defg";
WriteLine(message1.Insert(2, "abc"));
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
static void Main(string[] args)
{
string message1 = "hihihihihihihi";
string message2 = "abczzzdefg";
WriteLine(message1.Remove(2));
WriteLine(message2.Remove(3, 3));
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
static void Main(string[] args)
{
string message1 = "hi,hello, good morning";
string[] arr = message1.Split(',');
foreach (string word in arr)
{
WriteLine(word);
}
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
static void Main(string[] args)
{
String s1 = "안녕" + "하세요";
string s2 = String.Concat("안녕", "하세요");
string s3 = String.Concat(s1, s2);
WriteLine($"{s1} & {s2} & {s3}");
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
static void Main(string[] args)
{
string s1 = "안녕하세요";
char[] chArr = s1.ToCharArray();
foreach(char ch in chArr)
{
WriteLine(ch);
}
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
static void Main(string[] args)
{
// 문자열 묶는 가지 표현 방법
string fullName;
string firstName = "민승";
string lastName = "문";
fullName = firstName + lastName;
WriteLine(firstName);
fullName = "";
firstName = string.Format("{0}{1}", firstName, lastName);
WriteLine(firstName);
fullName = "";
fullName = $"{firstName}{lastName}";
WriteLine(firstName);
}
}
}
using System;
using static System.Console;
namespace testProject
{
class Program
{
static void Main(string[] args)
{
String s1 = "안녕하세요"; // String Class
string s2 = "안녕하세요"; // String keyword
WriteLine($"{s1} & {s2}");
WriteLine(s1.Equals(s2));
}
}
}