J
Joe DeAngelo
Is it possible to include assembler code into CSharp?
If yes, could someone give me an example?
Joe
If yes, could someone give me an example?
Joe
Joe DeAngelo said:Is it possible to include assembler code into CSharp?
If yes, could someone give me an example?
Ryan Riddell said:I'm fairly sure you can't do that. CSharp compiles into intermediate
language (IL) + Metadata. From there at runtime the IL is compiled
into machine specific code. Writing assembler code would break this
chain. You can however, execute other programs from within your C#
code. So if you could compile the Assembly code into an executable
you should be able to run that from your C# code.
Jon Skeet said:What would occasionally be useful would be the ability to include ILASM
in C# code - but you can't do that, either![]()
Daniel Jin said:Jon, I once had thought of this as well. but when I trying to find
what I can accomplish in IL that C# doesn't offer, I can't really
find anything particularly important. do you have anything in mind
where IL is absolutely necessary? very curious on what you can come
up with.
Is it possible to include assembler code into CSharp?
If yes, could someone give me an example?
The Doormouse said:Well, pardon my newbieness, but couldn't you include it as a resource or
DLL?
One of my books gives an example of writing a DLL in C#, but the finished
product - mustn't it be machine code?
can accomplish in IL that C# doesn't offer, I can't really find anythingDaniel Jin said:Jon, I once had thought of this as well. but when I trying to find what I
2) You can replace boxed values without unboxing/reboxing. For
instance, in a hashtable mapping string to int, you could increment the
value of the boxed int without all the
int x = (int)table[key];
x++;
table[key]=x;
Mattias Sjögren said:I used to advocate adding "inline ILAsm" support too, but I no longer
think the few situations where it would be useful justifies the
resources it would take to implement it.
To me, the Whidbey VC++ linker's support for linking modules into a
single file assembly is a better solution to the problem.
2) You can replace boxed values without unboxing/reboxing. For
instance, in a hashtable mapping string to int, you could increment the
value of the boxed int without all the
int x = (int)table[key];
x++;
table[key]=x;
If you do that a lot, perhaps you should consider writing a wrapper
class around the int and store that in the hashtable instead, to avoid
the (un)boxing.
class IntWrapper { public int x; }
(table[key] as IntWrapper).x++;
And then in Whidbey, you'd probably use a Dictionary<string,int>
instead.
Is that available outside VC++ though?
Also, can you create ILASM modules within Whidbey?