相关疑难解决方法(0)

如何将VB.NET中的扩展名移植到C#?

我在VB.NET中为StringBuilder写了一个扩展来添加一个AppendFormattedLine方法(所以我不必使用其中一个参数来换行符号):

Imports System.Runtime.CompilerServices
Public Module sbExtension
    <Extension()> _
    Public Sub AppendFormattedLine(ByVal oStr As System.Text.StringBuilder, _
                                   ByVal format As String, _
                                   ByVal arg0 As Object)
        oStr.AppendFormat(format, arg0).Append(ControlChars.NewLine)
    End Sub
    <Extension()> _
    Public Sub AppendFormattedLine(ByVal oStr As System.Text.StringBuilder, _
                                   ByVal format As String, ByVal arg0 As Object, _
                                   ByVal arg1 As Object)
        oStr.AppendFormat(format, arg0, arg1).Append(ControlChars.NewLine)
    End Sub
    <Extension()> _
    Public Sub AppendFormattedLine(ByVal oStr As System.Text.StringBuilder, _
                                   ByVal format As String, _
                                   ByVal arg0 As Object, _
                                   ByVal arg1 As Object, …
Run Code Online (Sandbox Code Playgroud)

c# vb.net stringbuilder extension-methods

1
推荐指数
1
解决办法
442
查看次数

标签 统计

c# ×1

extension-methods ×1

stringbuilder ×1

vb.net ×1