hey can anyone convert this c code into c#

#include<stdio.h>        

//Assume following return types while writing the code for this question.     
int output1;       

void GetBuildingCount(int marineCount,int marinePositions[][2])    
{      
int x,y,i,j,temp;
	for(x=0; x<marineCount; x++)
	{
	for( y=0; y<marineCount-1; y++)
	{
	if(marinePositions[y][0]>marinePositions[y+1][0])
			{
 temp = marinePositions[y+1][0];
marinePositions[y+1][0]=marinePositions[y][0];
	marinePositions[y][0] = temp;

			}
			
		if(marinePositions[y][0]>marinePositions[y+1][0])
			{
 temp = marinePositions[y+1][1];
marinePositions[y+1][1]=marinePositions[y][1];
	marinePositions[y][1] = temp;

			}
			

		}

	}
x=0;
y=0;
for(i=0;i<marineCount-1;i++)
{

if(marinePositions[i][0]==marinePositions[i+1][0])
continue;
else 
x++;
}
for(i=0;i<marineCount-1;i++)
{

if(marinePositions[i][1]==marinePositions[i+1][1])
continue;
else 
y++;
}






output1=(x+y)*8-x*y;	
	//Write code here    
}

Recommended Answers

All 3 Replies

It will probably work in C# if you take out the function and put it in a C# class.

You REALLY need to look up some proper formatting guidelines, or use an IDE.

Allthough you are not using any IO functions here, #include<stdio.h> will not work in C#, use using System; and other using clauses.

yes, we can do it kindly mail me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.