我如何使用裁剪功能 [英] How do I use the Trim Function
问题描述
我从VB转换Web项目到C#,我无法弄清楚如何实现微调功能。我必须写一个特定的功能,或者是有我的项目的上下文中使用它的方法吗?这里是功能VB code我尝试转换。如果您需要更多的详细信息,请询问。
保护小组ButtonSetup(BYVAL博士为DataRow的,BYVAL BTN为按钮)
Btn.Visible = TRUE
Btn.Text =博士(Floor_Name)。ToString.Trim()
Btn.CommandArgument =博士(Floor_File)。ToString.Trim()
Btn.CssClass =GreyButtonStyle
AddHandler的Btn.Click,AddressOf Me.Schematic_Button_Click
结束小组
索引
C#
使用括号 []
来访问索引,而不是括号的元素()
事件处理程序
的AddHandler
和 AddressOf
都是 VB
关键字。为了将处理程序添加到事件中,使用 + =
运营商,该事件为左操作数和处理程序作为右操作数。
保护无效ButtonSetup(DataRow的行,Button按钮)
{
button.Visible = TRUE;
。button.Text =行[Floor_Name]的ToString()修剪();
。button.CommandArgument =行[Floor_Name]的ToString()修剪();
button.CssClass =GreyButtonStyle;
button.Click + = Schematic_Button_Click;
}
I'm converting a web project from VB to C#, and I can't figure out how to implement the trim function. Do I have to write a specific function, or is there a way to use it in the context of my project? Here is the functional VB code I'm trying to convert. If you need more details, please ask.
Protected Sub ButtonSetup(ByVal Dr As DataRow, ByVal Btn As Button)
Btn.Visible = True
Btn.Text = Dr("Floor_Name").ToString.Trim()
Btn.CommandArgument = Dr("Floor_File").ToString.Trim()
Btn.CssClass = "GreyButtonStyle"
AddHandler Btn.Click, AddressOf Me.Schematic_Button_Click
End Sub
Indexer
C#
uses the square bracket[]
to access element of an indexer instead of parentheses()
Event Handler
AddHandler
and AddressOf
are both VB
keyword. In order to add an handler to an event, use the +=
operator with the event as left operand and handler as the right operand.
protected void ButtonSetup(DataRow row, Button button)
{
button.Visible = true;
button.Text = row["Floor_Name"].ToString().Trim();
button.CommandArgument = row["Floor_Name"].ToString().Trim();
button.CssClass = "GreyButtonStyle";
button.Click += Schematic_Button_Click;
}
这篇关于我如何使用裁剪功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!