Prev | Current Page 290 | Next

Guy Fouch?©, Trey Nash

"Accelerated VB 2008"

mReal = real
Me.mImaginary = imaginary
End Sub
Public ReadOnly Property Real() As Double
Get
Return mReal
End Get
End Property
Public ReadOnly Property Img() As Double
Get
Return mImaginary
End Get
End Property
'IFormattable implementation
Public Overloads Function ToString(ByVal format As String, _
ByVal formatProvider As IFormatProvider) As String _
Implements IFormattable.ToString
Dim sb As StringBuilder = New StringBuilder()
sb.Append("( ")
sb.Append(mReal.ToString(format, formatProvider))
sb.Append(" : ")
sb.Append(mImaginary.ToString(format, formatProvider))
sb.Append(" )")
Return sb.ToString()
End Function
End Structure
Public Class EntryPoint
Shared Sub Main()
Dim local As CultureInfo = CultureInfo.CurrentCulture
Dim germany As CultureInfo = New CultureInfo("de-DE")
Dim cpx As Complex = New Complex(12.3456, 1234.56)
Dim strCpx As String = cpx.ToString("F", local)
Console.WriteLine(strCpx)
strCpx = cpx.ToString("F", germany)
CHAPTER 9 n WORKING WITH STRINGS 179
Console.WriteLine(strCpx)
Dim dbgFormatter As ComplexDbgFormatter = New ComplexDbgFormatter()
strCpx = [String].Format(dbgFormatter, "{0:DBG}", cpx)
Console.WriteLine("" & vbCrLf & "Debugging output:" & _
vbCrLf & "{0}", strCpx)
End Sub
End Class
This example, whose output is identical to the last one, is a bit more complex (pun
intended).


Pages:
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
wierszyki życzenia pensjonaty w beskidach pozycjonowanie katalog stron