473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Integral Type for Switch ?

I want to do a switch statement on the value returned from getype(),
but the value is not an integral type. Is there a way to do something
besides gettype().ToString() and not use an if statement?
Nov 15 '05 #1
2 6676
Hi,

I have had the same problem, and concluded that you can only use a switch
if you convert the type to a string, like you mentioned.

If you still want to use the readl type, you can use a multi-level if..else
statement.

Bennie Haelen
"bdwise" <br************@hotmail.com> wrote in message
news:59**************************@posting.google.c om...
I want to do a switch statement on the value returned from getype(),
but the value is not an integral type. Is there a way to do something
besides gettype().ToString() and not use an if statement?

Nov 15 '05 #2
I'm afraid you'll have to stick to the string representation, but I'd
suggest using the FullName property on the returned System.Type instance
instead of ToString() to make the code more readable.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"bdwise" <br************@hotmail.com> wrote in message
news:59**************************@posting.google.c om...
I want to do a switch statement on the value returned from getype(),
but the value is not an integral type. Is there a way to do something
besides gettype().ToString() and not use an if statement?


Nov 15 '05 #3

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

Similar topics

3
by: Dave | last post by:
Hello all, Suppose you have an unsigned integral type T. It's not one of the built-in types, but rather typedefed off of one of the built-in unsigned integral types (but we don't know which...
0
by: Roman S. Golubin | last post by:
Hello everybody! I have been installed Visual C#.Net 2003 Standard and I don't found "Output type" switch in project properties ????!!! ;-((( Can someone help me for correct this mistake?...
6
by: anongroupaccount | last post by:
class CustomType { public: CustomType(){_i = 0;} CustomType(int i) : _i(i) {} private: int _i; }; class MyClass
18
by: u.int.32.t | last post by:
How do you suggest iterating from some size_t M down to 0? The obvious way is: for(size_t i = M+1; i > 0; --i){...} Another way is to depend on wraparound... Any suggestions?
10
by: Tomás | last post by:
When you simply want to store a number, what integral type do you use? For instance, let's say we have the following in a Poker game: struct Card { enum Suit { Hearts, Diamonds, Spades, Clubs...
4
by: =?Utf-8?B?QUEyZTcyRQ==?= | last post by:
I am getting this error with a switch statement: what doe it mean? int res = new int {Convert.ToInt32(arg1 is string), Convert.ToInt32(arg2 is string)}; switch (res) { case new int{0,0}: {...
2
by: Ranganath | last post by:
Hi, Why is there a restriction that only integral types can be made static constant members of a class? For e.g., class B { private: static const double K = 10; };
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

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.