C ++与C# [英] C++ versus C#

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

问题描述

大家好,

如何将该C ++函数转换为CSharp ..?我只是想学习c#编程的新手..

Hello Guys,

How can I convert this C++ function into CSharp..? I am just a newbie that want''s to learn c# programming..

short MES_EditConfig(char *Detail, char *aParameter)
{
FILE 	*fp;
char 	*fData;
char	fTemp[80];
char 	prjdef[512];
long 	FileSize;

char 	sString[500];
long 	sIndx;
char 	*strCmp;
long 	sCnt;
char 	str_newDetail[50];
int 	len_newDetail;

int 	ErrorFlag=0;

char 	*strA, *strC;

GetProjectDir(prjdef);
sprintf(fTemp  , "%s\\Config.ini", prjdef);

FileSize = GetFileData(fTemp, &fData);
sIndx=0;
sCnt=0;
strCmp = fData;

sprintf(str_newDetail, "%s%s\n", Detail, aParameter);
len_newDetail = strlen(str_newDetail);

while(sCnt<filesize-1)>
{
	while(fData[sCnt]!=10 && sCnt<filesize-1)>
		sCnt++;
	
	CopyString(sString, 0, fData, sIndx, sCnt - sIndx);
	
	if(!strncmp(sString, Detail, strlen(Detail)))
	{
		strA = malloc(sIndx+1);
		strC = malloc(FileSize-sIndx);
			
		CopyString(strA, 0, fData, 0, sIndx);
		CopyString(strC, 0, fData, sCnt+1, -1);
		sprintf(fData, "%s%s%s", strA, str_newDetail, strC);
		
		ErrorFlag=1;
	}
		
	sCnt++;
	sIndx = sCnt;
}

fp = fopen(fTemp, "w");
fputs(fData, fp);
fclose(fp);
return ErrorFlag;
}

推荐答案

我建​​议您从学习C#本身开始.看看 .NET零本书 [ ^ ],这是C#入门的绝佳方法.
I would suggest you start by learning C# itself. Take a look at .NET Book Zero[^] by Charles Petzold, an excellent way to get started with C#.


您的函数是C,而不是C ++.无论如何,如果您想学习C#,将C代码转换为C#几乎不是最好的方法.找到一些C#书籍并从中学习.
Your function is C, not C++. Anyway, if you want to learn C#, converting C code to C# is hardly the best way to do it. Find some C# book and learn from it.


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

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