CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2004
    Posts
    346

    Usng header file defines in C# Code

    i need to create a header (*.h) file with these defines :

    #define MY_FIRST_DEFINE 1
    #define MY_SECOND_DEFINE 2
    #define MY_THIRD_DEFINE 3

    and use it in a cs file - C# Code.

    How do i include it ?
    do i need to write a special code in the header file ?
    do i need to write a special code in the C# file ?

    thanks.

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Usng header file defines in C# Code

    That's not going to work. You cannot use C++ files in C#. Simply create a cs file with an enumeration:
    Code:
    public enum Defines
    {
    MY_FIRST_DEFINE = 1,
    MY_SECOND_DEFINE = 2,
    MY_THIRD_DEFINE = 3
    }
    Or you could make it a static class if you want.
    Code:
    public static class Defines
    {
      public const int MY_FIRST_DEFINE = 1;
      public const int MY_SECOND_DEFINE = 2;
      public const int MY_THIRD_DEFINE = 3;
    }
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

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

Featured