... | ... | @@ -203,7 +203,7 @@ st.Stop(); |
|
|
Console.WriteLine("Second : ", st.ElapsedTicks / 10000 / 1000);
|
|
|
```
|
|
|
_ _ _
|
|
|
### **4. String 대표 method 정리**
|
|
|
### **4. [String 대표 method 정리](#third)**
|
|
|
|
|
|
| **member** | **type** | **description** |
|
|
|
|--------|--------|--------|
|
... | ... | @@ -467,7 +467,7 @@ private static void DoMethod() |
|
|
<img src="FourthImage/7.png" width="400">
|
|
|
|
|
|
* * *
|
|
|
##### **#B using keyword**
|
|
|
##### <a name = "second">**#B using keyword**
|
|
|
FileLogger class에 IDisposable interface가 구현돼 있다면 FileLogger instance를 Dispose하기전에 exception이 발생할 수 있으므로 다음과 같이 구현한다.
|
|
|
|
|
|
``` cs
|
... | ... | @@ -492,7 +492,7 @@ static void Main(string[] args) |
|
|
}
|
|
|
}
|
|
|
```
|
|
|
c#은 try/finally를 대신하는 using keyword를 제공한다.
|
|
|
c#은 try/finally를 대신하는 [using keyword](#second)를 제공한다.
|
|
|
``` cs
|
|
|
// 블록이 끝나는 시점에 Dispose method 자동 호출
|
|
|
using (FileLogger log = new FileLogger("sample.log"))
|
... | ... | @@ -501,7 +501,7 @@ using (FileLogger log = new FileLogger("sample.log")) |
|
|
}
|
|
|
```
|
|
|
* * *
|
|
|
##### **#C String 대표 method example **
|
|
|
##### <a name = "third">**#C String 대표 method example **
|
|
|
``` cs
|
|
|
// String.Format
|
|
|
string strFormat = String.Format("At {0}, the temperature is {1}°C.", DateTime.Now, 20.4);
|
... | ... | |