Unit.ToString 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將 Unit 轉換成對等字串。
多載
| ToString() | |
| ToString(CultureInfo) |
將 Unit 轉換成指定的文化特性中的相等字串。 |
| ToString(IFormatProvider) |
使用指定的格式提供者,將 Unit 轉換成對等字串。 |
ToString()
ToString(CultureInfo)
將 Unit 轉換成指定的文化特性中的相等字串。
public:
System::String ^ ToString(System::Globalization::CultureInfo ^ culture);
public string ToString (System.Globalization.CultureInfo culture);
override this.ToString : System.Globalization.CultureInfo -> string
Public Function ToString (culture As CultureInfo) As String
參數
- culture
- CultureInfo
CultureInfo,表示文化特性。
傳回
String 表示 culture 指定之文化特性中的這個 Unit。
備註
ToString使用 方法,將這個方法從 呼叫的 轉換為 Unit 指定文化特性中相等的字串。
另請參閱
適用於
ToString(IFormatProvider)
使用指定的格式提供者,將 Unit 轉換成對等字串。
public:
System::String ^ ToString(IFormatProvider ^ formatProvider);
public string ToString (IFormatProvider formatProvider);
override this.ToString : IFormatProvider -> string
Public Function ToString (formatProvider As IFormatProvider) As String
參數
- formatProvider
- IFormatProvider
IFormatProvider 介面實作,提供特定文化特性的格式資訊。
傳回
String,表示以 formatProvider 指定之格式顯示的這個 Unit。
備註
方法會 ToString 傳回以單位 Value 格式化的字串標記法,以及代表單位 Type 的縮寫。 下表列出 UnitType 值及其對應的縮寫。
| 單位類型 | 縮寫 |
|---|---|
| Pixel | px |
| Point | pt |
| Pica | pc |
| Inch | in |
| Mm | mm |
| Cm | cm |
| Percentage | % |
| Em | Em |
| Ex | 前 |
用來 formatProvider 指定用來格式化 Value 的文化特性特定資訊。 如果 為 formatProvider null ,則會使用目前文化特性的預設 NumberFormatInfo 物件集來格式化字串的數值部分。