Results 1 to 12 of 12

Thread: [RESOLVED] Getting the alias of variable types

  1. #1

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Resolved [RESOLVED] Getting the alias of variable types

    Is there an easy way to get the alias of variable types? To get string from System.String, etc...?

    TIA
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Getting the alias of variable types

    I'm not sure what you mean. Are you talking about string, int, bool, etc.?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Getting the alias of variable types

    Yes, is there an automated way which I may be missing?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Getting the alias of variable types

    An automated way to do what exactly? You just type them in the code window. Are you saying that you don't know what the intrinsic C# types are? There aren't too many and they're listed in a help topic entitled "Built-in Types Table", which also lists the corresponding .NET type.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Getting the alias of variable types

    Or you want to get all that types automatically to use them inside your program? This is common when creating an IDE or if someone wants to add some sort of intelllisense to a editor.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Getting the alias of variable types

    Quote Originally Posted by jcis
    Or you want to get all that types automatically to use them inside your program? This is common when creating an IDE or if someone wants to add some sort of intelllisense to a editor.
    Hmmm... that sounds like a legitimate reason, but I doubt that there's a way to get them in code. The list of C# keywords is only 97 long, so hard-coding that into something like an editor would not be too difficult.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Getting the alias of variable types

    I've made a mapper (in the link in my sig) and when I am reading the DataTypes of table columns it is using System.String, System.DateTime, etc, I had to use a switch to be able to get their alias but I am hoping there is already a function/method to do such which I may be just missing...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Getting the alias of variable types

    Quote Originally Posted by dee-u
    I've made a mapper (in the link in my sig) and when I am reading the DataTypes of table columns it is using System.String, System.DateTime, etc, I had to use a switch to be able to get their alias but I am hoping there is already a function/method to do such which I may be just missing...
    Why do you need to? It's the .NET type that's important I would think. A VB.NET Integer and a C# int are both implemented as a System.Int32, etc. What if the type is a date? There is no intrinsic date type in C# so you'd have to use DateTime, but in VB.NET you could use Date.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Getting the alias of variable types

    My brain maybe a little fuzzy, it just seem that I've read from somewhere that using the alias is better but I really can't recall where did I ran into this thought, or perhaps it's the other way around? When we use Set/Get properties is it just fine to use System.String instead of string only? I haven't seen any example that uses System.String in property get/set...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  10. #10
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Getting the alias of variable types

    In .NET (Vb.net/C#) variables has a GetType() property that brings the CTS type (The Common Type System). These are common type names inside .net framework (compatible between languages).
    See this links
    The Common Type System(CTS) benefits
    Data Types in C#
    I think that's what you're talking about.
    Last edited by jcis; Mar 10th, 2006 at 12:17 AM.

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Getting the alias of variable types

    It makes no difference whether you use the intrinsic data types of the current language or the .NET types in your code. The objects will still be implemented in exactly the same way and the MSIL will still be exactly the same. Intrinsic data types are a convenience when writing code but their use has no effect on the compiled assembly. You've used the term "alias" in your posts and that's exactly what they are: just another name for exactly the same thing. Like I said, all intrinsic data types are implemented using a .NET type.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  12. #12

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Getting the alias of variable types

    Sorry but I get it now, I was wrong in the first place, it was actually string against using String, etc...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width