Help with understanding C# code and porting to Objective-C
c#, declaration, methods, objective-c, porting
Solution
The fourth and fifth lines are constructors in C#. They are the equivalent to [[c_data alloc] init] chains in objective-c. C# allows you to overload constructors based on the parameters they take. This is equivalent to having two different initialization methods in Objective-C:
@interface CData : NSObject
{
double value;
int label;
int ID;
}
@property double value;
@property int label;
@property int ID;
-(id) init;
-(id) initWithValue:(double)value;
@end
Problem
Ok, I have this prototype that was written by someone else in C# and I'm trying to put it into Objective-C. Now, I haven't had any formal experience with C# yet, so I don't know everything about it yet. I understand what the first three variables are, but I'm running into problems with what the fourth and fifth lines (c_data) are doing. Is the fourth declaring a method and then the fifth defining it or what's happening? Thanks for your help! ``` public class c_data { public double value; public int label; public int ID; public c_data() { } public c_data(double val) { value = val; } } ```