C#等效语法 [英] C# equivalent syntax

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

问题描述

大家好

请帮助我使用C ++代码后的

的C#等效语法。非常感谢提前。


double * firstVal;

int secondVal;

double thirdVal;

int fourthVal;


firstVal = new double [secondVal];

*(firstVal + thirdVal)= fourthVal;


delete [] firstVal;

Hi all
Please help me with the C# equivalent syntax for the
following C++ code. Thanks a lot in advance.

double *firstVal;
int secondVal;
double thirdVal;
int fourthVal;

firstVal = new double[secondVal];
*(firstVal + thirdVal) = fourthVal;

delete [] firstVal;

推荐答案

我们很高兴C#没有那些指针!无论如何,那段代码没有多大意义


Tu-Thac


----- C#newcomer写道:----


您好

请帮助我使用C ++代码后面的

的C#等效语法。非常感谢提前


double * firstVal;

int secondVal

double thirdVal

int 4thVal


firstVal = new double [secondVal]

*(firstVal + thirdVal)= fourthVal


删除[ ] firstVal

Are we glad C# does not have those pointers! Anyways, that code does not make much sense

Tu-Thac

----- C# newcomer wrote: ----

Hi al
Please help me with the C# equivalent syntax for the
following C++ code. Thanks a lot in advance

double *firstVal;
int secondVal
double thirdVal
int fourthVal

firstVal = new double[secondVal]
*(firstVal + thirdVal) = fourthVal

delete [] firstVal


C#newcomer< an ******* @ discussion.microsoft.com>写道:
C# newcomer <an*******@discussions.microsoft.com> wrote:
请帮助我使用C / C语言后面的C#等效语法。非常感谢提前。

double * firstVal;
int secondVal;
double thirdVal;
int fourthVal;

firstVal = new double [secondVal];
*(firstVal + thirdVal)= fourthVal;

delete [] firstVal;
Please help me with the C# equivalent syntax for the
following C++ code. Thanks a lot in advance.

double *firstVal;
int secondVal;
double thirdVal;
int fourthVal;

firstVal = new double[secondVal];
*(firstVal + thirdVal) = fourthVal;

delete [] firstVal;




转换裸语法很少是一个好主意,特别是在这种情况下

,其中不一定是等价的。相反,告诉我们你要做什么

我们可以告诉你通常使用什么成语

C#。


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复小组,请不要给我发邮件



Converting bare syntax is rarely a good idea, especially in thise case
where there isn''t necessarily an equivalent. Instead, tell us what
you''re trying to do and we can tell you what idiom is usually used in
C#.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


你好C#newcomer,

欢迎来到C#:)
Hi C# newcomer,
Welcome to C# :)
double * firstVal;
你不能再使用指针了。你必须使用indeces访问int第二个项;
double thirdVal;
int fourthVal;

firstVal = new double [secondVal];
*(firstVal + thirdVal )= fourthVal;

delete [] firstVal;


int firstVal;

int secondVal;

double thirdVal;

int fourthVal;


//我假设所有的valrirables都被初始化

firstVal = 0;

double [] doubleArray = new double [secondVal];

doubleArray [firstVal + thirdVal] = fourthVal;


注意firstVal是索引而不是指针。这可能会影响你的程序逻辑。


-

B \ rgds

100

" C#newcomer" <一个******* @ discussions.microsoft.com>在留言中写道

新闻:6e **************************** @ phx.gbl ...嗨所有
请帮助我使用C / C语言代码的C#等效语法。非常感谢提前。

double * firstVal;
int secondVal;
double thirdVal;
int fourthVal;

firstVal = new double [secondVal];
*(firstVal + thirdVal)= fourthVal;

delete [] firstVal;
double *firstVal; you can''t use pointers anymore. You have to use indeces to access items int secondVal;
double thirdVal;
int fourthVal;

firstVal = new double[secondVal];
*(firstVal + thirdVal) = fourthVal;

delete [] firstVal;
int firstVal;
int secondVal;
double thirdVal;
int fourthVal;

//I assume all valrirables are initialized
firstVal = 0;
double[] doubleArray = new double[secondVal];
doubleArray[firstVal + thirdVal] = fourthVal;

Pay attention that the firstVal is index rather than pointer. This could
affect your program logic.

--
B\rgds
100
"C# newcomer" <an*******@discussions.microsoft.com> wrote in message
news:6e****************************@phx.gbl... Hi all
Please help me with the C# equivalent syntax for the
following C++ code. Thanks a lot in advance.

double *firstVal;
int secondVal;
double thirdVal;
int fourthVal;

firstVal = new double[secondVal];
*(firstVal + thirdVal) = fourthVal;

delete [] firstVal;



这篇关于C#等效语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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