|
-
November 23rd, 2004, 08:44 PM
#1
Getting the length of a string
Hey there,
I'm trying to get the length of a string so that I can determine when to stop copying items from it.
I have a string
System::String *szSourceLine;
which I load with a line from a file. (This is working correctly).
I am trying to find the length of this atring. I tried using both
szSourceLine->get_Length() and szSourceLine->Length();
but it gives me the error:
"term does not evaluate to a function taking 0 arguments"
Does anyone have any information about this?
Or if you have any information on another way to determine if you are at the end of a string, that would also be helpful. I was using
szSrcLine->get_Chars(i);
to get the characters out of the string, and thenprocess them. But once I reach the end of the string, I run into errors since I am accessing over the length of the string.
If you have any ideas on this, please let me know. It would be greatly appreciated.
Thanks
Danielle
-
November 23rd, 2004, 08:58 PM
#2
Re: Getting the length of a string
get_Length is a property, so the way to access it is to use Length
Code:
szSourceLine->Length;
Properties work in the following way. If you define a function as a property as below
Code:
public __gc class MyClass
{
private: int variable;
//Note : you cannot use get_varaible
public:__property int get_Variable(){return variable);
public:__property int set_Variable(int NewVaraible){_variable = NewVaraible);
};
you then use it like this
Code:
MyClass* MyInstance = new MyClass();
MyInstance ->Variable = 6;
//more stuff
int Val = MyInstance->Variable;
I hope this clears this up for you. If not, there is a lot on __property in MSDN
Cheers
Lloydy
-
November 23rd, 2004, 10:45 PM
#3
Re: Getting the length of a string
Thanks,
your suggestion worked. I'm also going to take a look at __property in MSN this week.
Danielle
-
November 24th, 2004, 12:31 AM
#4
Re: Getting the length of a string
Don't forget to rate the post
Lloydy
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
|