Translation of most VB.NET->C# (and other way around) is pretty simple but with a few things that are specific to one language and not the other. One thing that you could do to learn how one thing is written in language X vs. language Y is look at the direct translation from MSIL. You can download .NET Reflector from -> http://www.aisto.com/roeder/dotnet/[^] and load in an assembly with the above method in it (must be compilable at this point) and .NET Reflector will allow you to toggle between VB.NET and C#. .NET Reflector merely looks at the IL and translates to the language of choice from that (in most cases you can simply recompile from it as it does a fairly good job at it). Hope this helps a little, Cheers, -t
Travis D Mathison
Posts
-
Convert this VB code to C# -
Permisions in windows vistaHey Arslan, This is due to the way Vista handles elevation of privilages on accounts (even ones that do have permissions to do things such as start/stop services). You can verify this by running your application as an Administrator (ie. right click and "Run as administrator" with your admin account). You will also be able to run a debug session after start Visual Studio in the same manor (there are things to be aware of when doing this though). Please reference this site for more information on these things you're experiencing http://msdn.microsoft.com/en-us/vs2005/aa964140.aspx[^] Cheers, -t
-
VS2003 and VS2005 on the same machine (WTF)As Nish said, you should try going to the virtual server in IIS that's hosting your ASP.NET application and make sure that it's set to use version 1.1 (you should have an ASP.NET tab with a dropdown for both 1.1.4322 and 2.0.50727). If that doesn't work you could try re-registering ASP.NET 1.1 via the aspnet_regiis.exe utility found in C:\Windows\Microsoft.NET\Framework\v1.1.4322 (aspnet_regiis.exe -i).
-
ArrayYes you can, you just have to remember to new up each panel in the array prior to use...
-
??? about firewalled environment ???Well, as far as getting the proxy settings from IE -- You can grab the ProxyServer value from HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer (REG_SZ); how you use this depends on what you're connecting to obviously...
RegistryKey key = Registry.CurrentUser; key = key.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings"); Console.WriteLine(key.GetValue("ProxyServer"));
-- modified at 7:07 Monday 16th October, 2006 -
Vista licensing againSorry but this just doesn't make sense... how can it be assumed that everybody will "at most" have only two computers within the lifecycle of Vista? That is absurd given you'd have to buy -another- copy of Vista...
-
And another Vista questionI highly doubt you'll have to do it every couple months... then again, I'm surprised with the limited moves in the Vista licensing (not sure how Microsoft can assume you will only go through 2 machines during Vista's lifecycle).
-
Session State variables within UserControls [modified]Scenario: - I have session state variables being saved and loaded from an ASP.NET page. - I have session state variables being set from within a UserControl that exists on that same page. Problem: - When I set a session state variable within the codebehind page of the UserControl and the page performs a postback I am unable to access the session state variable that was set within the UserControl during the OnInit method of the ASP.NET page that the control is on? - I am checking this by enumerating the session state variable collection for the page at both the OnInit and OnLoad methods of the page and the controls session state variables are not available at either. However, after the page has loaded I look at the trace information and see that the user controls session state variables are there (but not in the collection during the pages OnLoad event....) Question: - In regards to the accessability of the UserControls session state variables on the page: Are the session state variables loaded into the pages session state collection during the loading of the control itself (which is why I cant access them during the OnInit phase of the Page itself?) - Shouldn't Session state variables be accessable to the page and all children controls of that page for that user? I'm going to try to move some of the code that uses the session variable to a later rendering phase of which it's accessable however there is some things I'm doing that have to be done in the OnInit, OnPreRender, etc. page load phases... Thanks for any insight you can provide =P -- modified at 6:34 Friday 14th July, 2006
-
how to set the browser shortcuts to our owm browser applicationAh ok... well, same concept applies in that you should catch a Ctrl-Enter (and any other key press combo) and perform the url completion as needed. There are a few articles here on CodeProject that deal with the Url / Url History issues that you may want to check out // http://www.codeproject.com/csharp/ponta.asp[^]
-
ListView Control - Insert MethodThis is a kinda weird one then Garrett.. I've been trying to replicate the same issue here with a ListView using both Large Icon and Small Icon and have not been able to repro the sorting error. The icons and values of the indexes are being placed into the ListView exactly as expected (using the same code you supplied in your first post). If you're still having this issue I would do a line-by-line debug of each insert and step into each "Add" and "Insert" (F11) to see if you can catch where it goes bad --
-
How to update ComboBox/ListBox bound to ArrayList?Try calling the "Refresh" method on the comboBox to make it update instead of resetting its data source...
-
ListView Control - Insert MethodThe Insert method will indeed insert at index 0 of the ListView however if you are in Large/Small Icon view mode then by default the "AutoArrange" property will be set to "True" so it's going to sort the item regardless of the fact that you inserted it at index 0. Also check the "Sorting" property of the ListView control to make sure its set to "None" (the default).
-
Accessing form objectsSure, so if we had a label on the form that we wanted to update by code in some other class you would do the following: In your form code you would expose the label as a property...
delegate void Func();
...
public string MessageText
{
get
{
return label1.Text;
}
set
{
Func del = delegate
{
label1.Text = value;
};Invoke(del); }
}
Then we can create a new instance of the Btree class (in this case I'll just create it from the Load method of the form)
Btree myBtree = new Btree(this);
"this" refers to the Form class instance itself.. so for the constructor of the Btree class I'd have
public Btree(Form1 frm)
{
frm.MessageText = "This is a test";
}Since you have a reference to Form1 you can get/set properties and call methods on it. It is, however, better practice to create an interface that states what properties/methods the form should support of which other classes would make calls to so you dont tie yourself down to specific class/form names... but I dont think that would be a big concern for you at this point in time :P
-
ErrorSeems your installation of VS.NET is bad/corrupted, or the web components needed are not installed as expected.
-
NDOC ErrorWould it be safe to assume you're using VS2005? If so, there are known issues with NDoc 1.3.1 not supporting the 2.0 Framework (cant parse the solution files.. yada yada) reference http://sourceforge.net/mailarchive/forum.php?thread_id=10103851&forum_id=8193[^]
-
Accessing form objectsYour binary tree class (Btree) needs to get a reference to the Form class of which the label is on. There're a few different ways to handle the interaction between the two in regards to how loosely coupled you want them to be however the easiest thing to do would be to pass in a reference to the form object through the Btree constructor...
-
ReourcesReference the below links for potential resolutions to this issue: http://weblogs.asp.net/ngur/archive/2003/12/28/46219.aspx[^] http://www.avantbard.com/avantblog/?p=633[^]
-
ErrorHmmmm... Are you able to create new Web projects (ie. File->New->Web Site)? Or is this just when opening the existing Web Application? Have you tried deleting the sln/suo files and re-opening the project via the csproj file?
-
how to set the browser shortcuts to our owm browser applicationNot really sure what your problem is here, however, shortcuts for the browser component can be turned on/off via the WebBrowserShortcutsEnabled property (default is "True"). Are you trying to assign -new- shortcut keys to perform actions on the browser component? If so, I dont think the browser component itself has any additional features to assist in new shortcut keys; you need to catch the key presses yourself and perform the required custom actions from there.
-
File HidingWhat J4amieC said is probably exactly what's happening... If you want to set it all in one shot you can use:
File.SetAttributes(@"C:\test.txt", FileAttributes.Hidden | FileAttributes.ReadOnly);
If you want to add another attribute onto a file you need to add to the "existing" attributes, for example:
FileAttributes attr = File.GetAttributes(@"C:\test.txt");
File.SetAttributes(@"C:\test.txt", attr |= FileAttributes.Hidden);Hope that helps..