Click to See Complete Forum and Search --> : User defined types in CSharp
Silly Star
November 11th, 2008, 12:35 AM
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
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
MNovy
November 11th, 2008, 01:11 AM
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
DateTime myDate = new DateTime(2008,11,11);
Silly Star
November 11th, 2008, 01:32 AM
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
DateTime myDate = new DateTime(2008,11,11);
Thanks MNovy for suggestion but my emphases is user defined type conversion
HanneSThEGreaT
November 11th, 2008, 01:45 AM
struct
boudino
November 11th, 2008, 01:53 AM
Maybe. But why to have fields as string? Why not do it this way:
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?
Silly Star
November 11th, 2008, 02:54 AM
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
TheCPUWizard
November 11th, 2008, 06:51 AM
Be VERY aware of the differences between a struct and a class!!!!!!!!!!
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.