|
The easiest thing to do is to take the code that he has written in VB.NET that actually performs the functionality you need, and then make that into a class library. Then create a new C# Windows application and simply use the code from the class library to perform the functionlity you require.
So the steps would be,
1.) Create new Solution
2.) Create new VB project as a class library with the console code (well the bits that actually do the work)
3.) Create new C# project as a windows application and reference the VB class library
4.) Instantiate the class (or classes) of the VB class library from within the C# application and then use the functions as normal.
Hopefully that should sort you out.
Mark.
|
|
|
|
|
Okay, so then there's apparently nothing simple like setting a file that's part of a VB Project to use C# syntax. I wonder why not.
I understand about sharing DLLs; I just thought there'd be a way to code in more than one language in the same project.
Paul
|
|
|
|
|
You can add modules (contains the IL) compiled from different languages into a single assembly, but this does not produce a single file. It produces a single manifest with multiple files, so you really gain nothing. See the documentation for the csc.exe C# command-line compiler (or the vbc.exe for VB.NET) in the .NET Framework SDK, specifically regarding the /target:module and /addmodule switches.
Linking assemblies is your best option. The .NET Framework itself is made up of dozens of assemblies; having your app be comprised of two assemblies is hardly an issue (and allows you to version assemblies independently, so long as you specify the proper version redirection if necessary).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Paul, while what Mark told you was correct, I just wanted to suggest another option however I feel what Mark suggested was the best choice for you. Because both code from a VB.NET and C# project will both compile down to the same MSIL instruction set you have many options. If you are having a problem understanding some of the VB.NET syntax, one thing that can be helpful is to load the assembly into Reflector[^] select the method or class you want to view and change the language in the drop-down to VB.NET.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Thanks for the extra tip, Nick. My problem isn't in understanding VB.NET, it's just that I don't like to code in it. I find VB.NET annoying to program in, after getting used to the conciseness of C++. Fortunately C# is not too far off.
|
|
|
|
|
I'm feeling a little dense here, but how do i do the C equivalent of
<br />
int array [16];<br />
int * p = array + 8;<br />
I've tried to look at the managed C++, but the program I'm using to convert to C# keeps crashing when I try to look at main()
|
|
|
|
|
Pointer manipulation requires an unsafe block around your code. However, depending on what you want to do with p, there might be a better managed solution than dropping into unsafe code.
|
|
|
|
|
Hmm, I think I'de prefer safe rather than sorry
Basically, I'm wanting to do something along these lines
<br />
int array [64];<br />
...<br />
...<br />
BitMangle (array + 8)
I come from a really heavy C/C++ background and I'm trying to get to grips with C# - I'm getting most of it, but this one little thing has me!
(ps - If there are some good book/articles I should read, do tell me)
|
|
|
|
|
cheesepirate wrote:
(ps - If there are some good book/articles I should read, do tell me)
You should read through the Arrays Tutorial[^] which covers single, multidimensional and jagged arrays in the C# Programmer's Reference.
- Nick Parker My Blog | My Articles
|
|
|
|
|
In C# you would just do
<br />
int[] array = new int[64];<br />
...<br />
BitMangle(array, 8);<br />
and the BitMangle method would be something like
<br />
void BitMangle(int[] array, int offset)<br />
{<br />
for (int i=offset; i<array.Length; i++)<br />
{<br />
}<br />
}<br />
|
|
|
|
|
cheesepirate wrote:
int * p = array + 8;
Sorry but that bad code in any language! what is 8? 2 or 4 ints? I mean any compiler could produce wrong code for that! Now if you did the following, life would be different, and at least someone else can understand the code.
int array [16];
int * p = &array[2];
And I can almost gaurentee you, that that will work now via MC++.
top secret xacc-ide 0.0.1
|
|
|
|
|
Greetings,
When I inherit from a user control I would like to rearange the controls of the base control on the new control. E.g. I have to list boxes side by side on the base control. I would like to change that to one list box above the other on the inherited control. The code for these controls are the same and I would like to get reuse out of this if possible.
Thank you,
Brett
|
|
|
|
|
Make the list boxes in the base control as public and do then rearranging.
|
|
|
|
|
True enough, how simple. Protected is probably a much safer bet though.
|
|
|
|
|
sssyed_in wrote:
Make the list boxes in the base control as public and do then rearranging.
I think protected would be more appropriate.
Charlie
if(!curlies){ return; }
|
|
|
|
|
Hi,
I have an object "obj" that is a TypeA. I have a Type object that refers to TypeA. How can I cast obj to TypeA? TypeA is dynamically created from a loaded assembly, so I need to be able to do it dynamically.
Or altenatively is there another way to get at obj's fields defined by the TypeA interface ?
thanks,
Matt
|
|
|
|
|
You gonna have to explain better, perhaps a code segment.
Dynamic casting is an urban legend, and is never required! (yes it does feel like u need it sometimes, but its not necessary, really)
top secret xacc-ide 0.0.1
|
|
|
|
|
maybe typeof() helps.
it will give the type of the object.
you should have cases of what types could obj be, it can't be just anything.
unless you should go for Generics in C# V2.0
find about generics here:
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=370
|
|
|
|
|
Not possible. Because of the Common Type System (CTS) - part of the .NET Framework - the type must be known at compile time or the necessary IL instructions cannot be emitted as part of the module that gets embedded into the primary assembly. The best alternative is to develop a base class from which all of your loaded types (common, especially in plug-in style applications) and cast to that base class, relying on polymorphism to define your distinct types' functionality (that derive from that base class, of course).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi
I have implemented a download facility in my web site..I need to update my database after downlaod has been completed...the problem that i am facing is, i cannot trap when the download has completed..and hence cannot updated my Database because ideally the Database should only be updated when the download has been completed.
Please Help
Ashu
|
|
|
|
|
Try the ASP.Net forum
Kev Pearman MCP
|
|
|
|
|
Thnx mate..
I have posted this problem on ASP.NET but still i would be very gr8ful to if you people could guide me a little in this regard..
Cheers
Ashu
|
|
|
|
|
How to get the "CPU Serial Number", "CPU Model Type", "Amount of RAM", "Video Controller ID" and "SCSI ID" using c#
P.Chandramohan
|
|
|
|
|
P.Chandramohan wrote:
CPU Serial Number
Thats only an optional P3 feature, thats off by default.
Most other info you can probably get thru System.Management and WMI. You have to refer to the MSDN WMI docs for more info (note: they are well hidden!).
top secret xacc-ide 0.0.1
|
|
|
|
|