473,795 Members | 3,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataType as class member

I have a class called "Prop". I want that class to have a property
called "DataType" where the user can select and store a datatype. How
can I store a DataType value in a class property.

how the code would work in my mind:

dim TempProp as new Prop
TempProp.DataTy pe = String

May 20 '06 #1
1 1182
You can use System.Type type and GetType operator for that purpose:

~
TempProp.DataTy pe = GetType(String)
~

But if you have a limited set of types you can allow, then you may
consider using an enum as well.

Roman

"Bryan" <br*******@gmai l.com> ???????/???????? ? ???????? ?????????:
news:11******** **************@ j33g2000cwa.goo glegroups.com.. .
I have a class called "Prop". I want that class to have a property
called "DataType" where the user can select and store a datatype. How
can I store a DataType value in a class property.

how the code would work in my mind:

dim TempProp as new Prop
TempProp.DataTy pe = String

May 20 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
1952
by: Eternally | last post by:
Hi folks, I've got a program which has a function which uses templates to accept parameters of any type. Works well, but there's one certain datatype which I want to special case and do an extra thing to. The datatype is a class I made. Is there anyway for me to test a parameters datatype in a template using function?
4
2499
by: Jian H. Li | last post by:
Hello, What's the essential differences between the two ways of "class::member" & "object.member"(or object_pointer->member)? class C{ public: void f() {} int i; };
9
2376
by: Steve | last post by:
Hello (and a happy new year) I'm quite new to C++ and have to programm something for school and can't get my head around a couple of things, but at the moment this one is the most important for me: I have defined a class String and before I go on I should mention that I'm not allowed to use any pre-defined templates (no STL) and not the standard C++ String class, kind of mean :)
3
1408
by: Adam Hartshorne | last post by:
Hi All, I have the following setup, and I was wondering what would be the best data type to achieve it. I have a class A, that stores a list of type X's and a list of type Y's. I also have a class B, that stores lists of type X's and type Y's . Class A also stores a list of class B's call it list L. Ok so I want to know how best to define type/class/struct of X and Y's
0
971
by: Omkar Singh | last post by:
hi, When I am serializing the array of following ParameterValueStruct class i didnot get 1> the type and size of array. 2> DataType of each element. It is especially needed in case of 'anyURI' DataType. I am using serializer class of XmlSerialization namespace of .NET framework. public class ParameterValueStruct {
5
14439
by: kuvpatel | last post by:
Hi I want to refer a class called LogEvent, and use one of its methods called WriteMessage without actually having to create an instance of Logevent. I have tried using the word sealed with the class and this works but I would also like to know of other ways to do this. Also are there any performance implacations of using sealed?
1
1283
by: al | last post by:
hi, I have a table that contain a field "amount" its datatype is numeric(18,4) in sql server 2000 I have created a Datagrid, when I edit a record, I get an error like this one BC30456: 'Numeric' is not a member of 'System.Data.DbType'. Line 213: dbParam_amount.ParameterName = "@amount" Line 214: dbParam_amount.Value = amount.text Line 215: dbParam_amount.DbType = System.Data.DbType.Numeric
14
33293
by: Dave Booker | last post by:
It looks like the language is trying to prevent me from doing this sort of thing. Nevertheless, the following compiles, and I'd like to know why it doesn't work the way it should: public class ComponentA { static string s_name = "I am the root class."; public string Name { get {return s_name;} } }
0
1181
by: =?Utf-8?B?VmFubmk=?= | last post by:
Hi all, I have the need to generate C# classes from XSD schemas, and the XSD.exe tool is just (almost) great for that. I said "almost" because it seems that every XML Schema datatype other than boolean is rendered as a String field/property. As an example, I am getting:
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.