Skip to content

Instantly share code, notes, and snippets.

@hachibeeDI
Created September 21, 2012 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hachibeeDI/3760291 to your computer and use it in GitHub Desktop.
Save hachibeeDI/3760291 to your computer and use it in GitHub Desktop.
Imports System.Runtime.CompilerServices
''' <summary> エイリアス的な拡張メソッドたち </summary>
Module StringExtention
''' <summary> </summary>
<Extension()> _
Public Function setFormat(this As String, ParamArray values As String()) As String
Return String.Format(this, values)
End Function
<Extension()> _
Public Function toStr_exlusDBNull(this As DataRow, columnname As String) As String
If this(columnname) Is DBNull.Value Then Return ""
Return this(columnname)
End Function
<Extension()> _
Public Function isInt(this As String) As Boolean
Return Integer.TryParse(this, Nothing)
End Function
''' <summary> C#のasみたいなもん </summary>
<Extension()> _
Public Function asInt(this As String) As Integer
If this.isInt Then Return CType(this, Integer)
Return 0
End Function
''' <summary> </summary>
<Extension()> _
Public Function setFormat(this As String, ParamArray values As String()) As String
Return String.Format(this, values)
End Function
End Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment