|
-
November 11th, 2008, 01:35 AM
#1
User defined types in CSharp
Hi
I created a project in VB6 and now converting it to CSharp
In my vb6 project i defined a User defined type as below
Code:
Type Dated
day As String
month As String
year As String
End Type
Now i want to convert it to CSharp (i searched it on the web but helpless)
How can i acomplish this in CSharp?
any help will be appreciated a lot
-
November 11th, 2008, 02:11 AM
#2
Re: User defined types in CSharp
Hi,
there is no need for own type for date, just have a look on the DateTime class, which is much more powerful, as you think.
Example
Code:
DateTime myDate = new DateTime(2008,11,11);
-
November 11th, 2008, 02:32 AM
#3
Re: User defined types in CSharp
 Originally Posted by MNovy
Hi,
there is no need for own type for date, just have a look on the DateTime class, which is much more powerful, as you think.
Example
Code:
DateTime myDate = new DateTime(2008,11,11);
Thanks MNovy for suggestion but my emphases is user defined type conversion
-
November 11th, 2008, 02:45 AM
#4
Re: User defined types in CSharp
-
November 11th, 2008, 02:53 AM
#5
Re: User defined types in CSharp
Maybe. But why to have fields as string? Why not do it this way:
Code:
public struct Dated
{
public int day;
public int month; As String
public int year;
}
But I have another question: does it make sence to have strings as members of a struct? More generally: does it make sence to have reference type as members of a struct?
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post. 
-
November 11th, 2008, 03:54 AM
#6
Re: User defined types in CSharp
heartiest thanks for the help.
Really it does not make any sense to define day,month,year as string.
The code was just an example and your help made me capable to step ahead.
Silly
-
November 11th, 2008, 07:51 AM
#7
Re: User defined types in CSharp
Be VERY aware of the differences between a struct and a class!!!!!!!!!!
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
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
|