|
-
Feb 18th, 2005, 08:43 AM
#1
Thread Starter
Fanatic Member
Convert C class to C# ??
Is there an easy way to do this? Or....does it have to be done one step at a time?
Thanks!
-
Feb 18th, 2005, 03:04 PM
#2
Re: Convert C class to C# ??
 Originally Posted by birthjay
Is there an easy way to do this? Or....does it have to be done one step at a time?
Thanks!
eh C has nothing to do with C#, they just have a similar syntax. hehe I think you have to go through painful step by step translation
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Feb 18th, 2005, 08:14 PM
#3
Sleep mode
Can you show the C class maybe the function you're trying to translate is already exist in the FW.
-
Feb 21st, 2005, 08:53 AM
#4
Thread Starter
Fanatic Member
Re: Convert C class to C# ??
Well...just as an example...How would this convert to C#:
compute_solution (solu,posit,x,y)
float *solu, *posit, *x, *y;
{
*solu= hypot(*x,*y);
*posit =atan2(*y,*x);
}
-
Feb 21st, 2005, 02:48 PM
#5
Sleep mode
-
Feb 21st, 2005, 03:43 PM
#6
Thread Starter
Fanatic Member
Re: Convert C class to C# ??
Thanks. I have seen the "Unsafe" thing, but I really want to go straight away to C#. The "Unsafe" thing seems to be a work-a-round. Am I wrong on that?
-
Feb 21st, 2005, 04:24 PM
#7
Re: Convert C class to C# ??
 Originally Posted by birthjay
Thanks. I have seen the "Unsafe" thing, but I really want to go straight away to C#. The "Unsafe" thing seems to be a work-a-round. Am I wrong on that?
umm for security reasons, you can only and only use pointers in C# using unsafe{}. No way around that either
the point is, when you use unsafe then the .NET framework will only run your app on someone's comp if the security settings are not too tight. It's just to avoid system damage etc and all those viruses that rely on pointers
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Feb 21st, 2005, 04:36 PM
#8
Thread Starter
Fanatic Member
Re: Convert C class to C# ??
Thanks...
Well..say in the code below...can I just pass by "ref" and accomplish the same thing?
compute_solution (solu,posit,x,y)
float *solu, *posit, *x, *y;
{
*solu= hypot(*x,*y);
*posit =atan2(*y,*x);
}
-
Feb 21st, 2005, 04:45 PM
#9
Re: Convert C class to C# ??
 Originally Posted by birthjay
Thanks...
Well..say in the code below...can I just pass by "ref" and accomplish the same thing?
compute_solution (solu,posit,x,y)
float *solu, *posit, *x, *y;
{
*solu= hypot(*x,*y);
*posit =atan2(*y,*x);
}
aah sorry I dont even understand what that code does
but if you want to pass things by reference here's how to do it in c# (and, no, for this one you wont need the unsafe block)
Code:
private void Form1_Load(object sender, System.EventArgs e)
{
int num=9;
testing (ref num);
MessageBox.Show (num.ToString());
}
private void testing (ref int num)
{
num*=9;
}
so when you call the function and you are passing the parameter, you need to put the REF keyword before the parameters name. And same applies in the function header
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Feb 21st, 2005, 04:47 PM
#10
Thread Starter
Fanatic Member
Re: Convert C class to C# ??
Ok..thank you all for the good info.
-
Feb 21st, 2005, 08:23 PM
#11
Sleep mode
 Originally Posted by birthjay
Well...just as an example...How would this convert to C#:
compute_solution (solu,posit,x,y)
float *solu, *posit, *x, *y;
{
*solu= hypot(*x,*y);
*posit =atan2(*y,*x);
}
hypot
double hypot( double x, double y)
HEADER math.h
PURPOSE
To return the square root of .x times x plus y times y.
atan2
double atan2 (double first, double second)
HEADER math.h
PURPOSE
To calculate the value of the arc tangent of first divided by second, using the signs of both arguments to calculate its quadrant.
These functions are available in .NET under Math class . So , there's no need to rewrite your code . Your code just store the return type into float variables which is also possible in C#.
System.Math.Atan2 (y,x);
System.Math.Sqrt(x);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|