使用C#进行转换 [英] Casting in C#

查看:74
本文介绍了使用C#进行转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下VB的C#equivelant是什么:


CType(controlTemplate,TextBox).Text =""


我基本上试图在我的函数中使用一个更通用的对象作为参数,然后根据其类型更改函数内的行为

。 br />

问候,

David P. Donahue
dd ****** @ ccs.neu.edu

What is the C# equivelant of the following VB:

CType(controlTemplate, TextBox).Text = ""

I''m basically trying to use a more general object as an argument in one
of my functions and then change the behavior within the function based
on its type.

Regards,
David P. Donahue
dd******@ccs.neu.edu

推荐答案

David,


你会这样做:


//转换为文本框并设置文本属性。

((TextBox)controlTemplate).Text = string 。空;


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]
- mv*@spam.guard.caspershouse.com


David P. Donahue <峰; dd ****** @ ccs.neu.edu>在消息中写道

新闻:Og ************** @ TK2MSFTNGP09.phx.gbl ...
David,

You would do this:

// Cast to a textbox and set the text property.
((TextBox) controlTemplate).Text = string.Empty;

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"David P. Donahue" <dd******@ccs.neu.edu> wrote in message
news:Og**************@TK2MSFTNGP09.phx.gbl...
什么是C#equivelant下面的VB:

CType(controlTemplate,TextBox).Text =""

我基本上试图使用更通用的对象作为参数我的功能之一,然后根据其类型更改功能中的行为。

问候,
David P. Donahue
dd ****** @ ccs.neu.edu
What is the C# equivelant of the following VB:

CType(controlTemplate, TextBox).Text = ""

I''m basically trying to use a more general object as an argument in one of
my functions and then change the behavior within the function based on its
type.

Regards,
David P. Donahue
dd******@ccs.neu.edu



嗨David,


使用:

((TextBox)controlTemplate).Text =""

HTH,

Rakesh Rajan


" David P. Donahue"写道:
Hi David,

Use:
((TextBox)controlTemplate).Text = ""

HTH,
Rakesh Rajan

"David P. Donahue" wrote:
以下VB的C#equivelant是什么:

CType(controlTemplate,TextBox).Text =""
<我基本上试图在我的函数中使用一个更通用的对象作为参数,然后根据其类型改变函数内的行为。
David P. Donahue
dd******@ccs.neu。 edu
What is the C# equivelant of the following VB:

CType(controlTemplate, TextBox).Text = ""

I''m basically trying to use a more general object as an argument in one
of my functions and then change the behavior within the function based
on its type.

Regards,
David P. Donahue
dd******@ccs.neu.edu



equivelent是演员运营商


((TextBox)controlTemplate).Text ="";


问候


Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog


什么是以下VB的C#equivelant:


CType(controlTemplate,TextBox).Text =""


我基本上是试图使用一个更通用的对象作为我的函数的一个参数,然后根据其类型更改函数内的行为


The equivelent is the cast operator

((TextBox)controlTemplate).Text = "";

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

What is the C# equivelant of the following VB:

CType(controlTemplate, TextBox).Text = ""

I''m basically trying to use a more general object as an argument in one
of my functions and then change the behavior within the function based
on its type.


这篇关于使用C#进行转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆