新版C#会让我这样做吗 [英] will new version of C# let me do this

查看:77
本文介绍了新版C#会让我这样做吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我可以使用if语句中的可用内容,那将会很酷。

代码块

例如

if (g> 3434){g = rightHandValue}


g如果大于3434则不会是3434

Gary Brewer

It would be cool if I could use what I evaulate in an if statement useable
in its code block
for example
if(g>3434) { g=rightHandValue }

g would not be 3434 if it was bigger than 3434

Gary Brewer

推荐答案

Gary,


这很容易实现。


g =数学.Min(g,3434);


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C# MVP]

- ni ********** ****@exisconsulting.com


" Gary Brewer" < no@spam.for.me.thanks.com>在消息中写道

news:%2 ****************** @ TK2MSFTNGP10.phx.gbl ...
Gary,

This is easily accomplished.

g = Math.Min(g, 3434);

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"Gary Brewer" <no@spam.for.me.thanks.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
如果我可以在其代码块中使用if语句中可用的内容,那将会很酷。

例如

if(g> 3434){g = rightHandValue}

g如果大于3434则不会是3434


It would be cool if I could use what I evaulate in an if statement useable
in its code block
for example
if(g>3434) { g=rightHandValue }

g would not be 3434 if it was bigger than 3434

Gary Brewer



这在c#中不起作用吗?


g =(g> 3434?3434:g);


Chris 。

" Gary Brewer" < no@spam.for.me.thanks.com> ha scritto nel messaggio

新闻:%2 ****************** @ TK2MSFTNGP10.phx.gbl ...
Doesn''t this work in c#?

g = ( g>3434 ? 3434 : g );

Chris.
"Gary Brewer" <no@spam.for.me.thanks.com> ha scritto nel messaggio
news:%2******************@TK2MSFTNGP10.phx.gbl...
如果我可以在其代码块中使用if语句中可用的内容,那将会很酷。

例如

if(g> 3434){ g = rightHandValue}

如果它大于3434,则不会是3434


It would be cool if I could use what I evaulate in an if statement useable
in its code block
for example
if(g>3434) { g=rightHandValue }

g would not be 3434 if it was bigger than 3434

Gary Brewer


< br>

2003年8月21日星期四14:17:30 +0100,Gary Brewer< no@spam.for.me.thanks.com>

写道:
On Thu, 21 Aug 2003 14:17:30 +0100, Gary Brewer <no@spam.for.me.thanks.com>
wrote:
如果我能在if语句中使用我在其代码块中使用的


,那将会很酷。

if(g> 3434){g = rightHandValue}

如果大于3434,g不会是3434



It would be cool if I could use what I evaulate in an if statement
useable
in its code block
for example
if(g>3434) { g=rightHandValue }

g would not be 3434 if it was bigger than 3434

Gary Brewer




g = g> 3434? g:3434;


转换为if(g> 3434){g = g} else {g = 3434}


-

使用M2,Opera的革命性电子邮件客户端: http://www.opera.com/m2/


这篇关于新版C#会让我这样做吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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