First of all, I'm an absolute C# newbie. But I want to start using the language for development. My question is, Can I use a library written for C in C#? If so, can someone provide a simple example on how to do this?
Thanx
Bob
Printable View
First of all, I'm an absolute C# newbie. But I want to start using the language for development. My question is, Can I use a library written for C in C#? If so, can someone provide a simple example on how to do this?
Thanx
Bob
http://msdn.microsoft.com/library/de...ClassTopic.asp
Example:Code:using System;
using System.Runtime.InteropServices;
namespace TextColor
{
class MainClass
{
[DllImport("kernel32.dll")]
public static extern bool SetConsoleTextAttribute(IntPtr hConsoleOutput, int wAttributes);
[DllImport("kernel32.dll")]
public static extern IntPtr GetStdHandle(uint nStdHandle);
public static void Main(string[] args)
{
uint STD_OUTPUT_HANDLE = 0xfffffff5;
IntPtr hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
for (int k = 1; k < 255; k++)
{
SetConsoleTextAttribute(hConsole, k);
Console.WriteLine("{0:d3} http://www.cprogramming.com", k);
}
SetConsoleTextAttribute(hConsole, 236);
Console.WriteLine("Press Enter to exit ...");
Console.Read();
}
}
}
BMJ,
Thanx for the example
Bob