[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

I have a switch statement to compare a datagrid column type to a constant.  How do I assign a DateTime type to a constant.  I tried using type of but that is run time

Posted on 2010-08-25
1
Medium Priority
?
280 Views
Last Modified: 2012-05-10
Please see attached code.  Constant declaration is not right because it is at runtime.
public const string cstrDateTime = typeof(System.DateTime).ToString();


switch (ColomnType)
                        {
                            case cstrInt:
                                // Output Integers as numbers
                                msoStyle = "";
                                break;

                            case cstrDateTime:
                                // Output dates as MM/dd/yyyy
                                msoStyle = "mso-number-format: mm\\/dd\\/yy";
                                break;

                            default:
                                // Output other values as string
                                msoStyle = "mso-number-format: \\@";
                                break;
                        }

Open in new window

0
Comment
Question by:MichBman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
thepanch earned 2000 total points
ID: 33525058
object cstrDateTime = new DateTime(); //this line set the type DateTime to the object

            if (cstrDateTime.GetType().Name.ToString()=="DateTime") //compare the Type of the object
            MessageBox.Show(cstrDateTime.GetType().ToString()); //just do something if its true.

I hope it helps
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question