Hi, I recently developed a program which has source and header files in vc++! what I want to do is convert the same in C#. I got the idea of source files but how to import/use header files in C#(I want seperate file for class creation/ data initialization like header files)? help me!

C# does not use header files.
Everything is contained in the class itself.

The framework reads the "assembly" to determine what is available to other classes that call it.
You can put your classes in separate files or in separate projects.

Even if you are calling them from c++, you won't need a header.

"You can put your classes in separate files or in separate projects."
Can I create class in seperate .cs file? Then how to call or refer to it in my main .cs file.

If the class is in the same namespace, you can just use it like a regular class.
If it is in a different namespace, you add "using ThatNamespacName;" at the top of the module that will be using it.

old topic but if you want to use .h files with C# it really depends upon what youre trying to accomplish:

For instance i am writing a memorystream picture box that will display a bitmap
So i used bin2c to create the .h header file which contains my bitmap as a byte array which can be streamed
so it would be something like
bin2c -o bit.h image.bmp
Bin2c will creat the bit.h with the file array as a:

/* Generated by bin2c, do not edit manually */
/* Contents of file fake_login1.bmp */
const long int fake_login1_bmp_size = 37676;
const unsigned char fake_login1_bmp[37676] = {  ... array of bytes ... }

delete the const long int fake_login1_bmp_size = 37676;
change the const unsigned char fake_login1_bmp[37676] to:

public static byte[] bit =  { ... array of bytes .. }

add the class

so in all it would look like:

/* Generated by bin2c, do not edit manually */
public class Test
{
public static byte[] bit = {  .. array ...};
}

then to compile the header with your app:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc /target:exe /out:123.exe 123.cs bit.h

===================
to actually use the header byte array it would be something like:
System.Drawing.Image newImage;
MemoryStream stream = new MemoryStream(Test.bit);
newImage = System.Drawing.Image.FromStream(stream);

its basically creating a class which only contains your "data" or "variable" which yu can call.. make sure its a public class and a public static "variable" ie: byte[] array so that it can be accessed by any function

Lastly: if youre trying to use .h files which contain functions written for C++
its not going to happen, you'll need to convert the C++ API into the C# API with [DLLImport]

If its a C# class within a .h file its no different than that of main.cs class1.cs class2.cs class3.h class4.h

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.