This question already has answers here:
Does C# Support Project-Wide Default Namespace Imports Like VB.NET?
(5 answers)
Closed 5 years ago.
Is there a way to apply the reference " using mysql.data " to all windows forms in a project by not going to each form and typing it manually? Like an option from the solution explorer.
Here's one approach:
Edit -> Find And Replace -> Find in Files
in Find what box write: using System;
in Replace with box write: using System;\r\nusing mysql.data;
in Find options group check use regular expressions and in Look at these file types add *.cs
Related
This question already has answers here:
What does hash sign # do in the C# especially in if-else Statements?
(2 answers)
Closed 4 months ago.
I am trying to figure out how to disable this IF statement so the code doesn't run unfortuanately I dont know what this IF statement is called so Im having trouble googling it.
I have tried searching for solutions online and looking in files.
That's a C# conditional compilation directive.
If you right-click on your project in Solution Explorer and go to Build > General > Conditional compilation symbols, you'll see the 'symbols' that are set and can be used in those #if statements. Typically you configure different symbols depending on the type of build you're running.
This question already has answers here:
HttpUtility does not exist in the current context
(10 answers)
Closed 5 years ago.
I'd like to use HttpUtility.HtmlDecode() to process some strings in my application, but for some reason Visual Studio doesn't seem to know where it's at.
I'm fairly new to C# so I'm just guessing I've missed something like importing a library, but I don't even know what to Google.
I've tried using System.Web but it only seems to contain AspNetHostingPermission and friends, no HttpUtility.
I'm using VS2015 Community Edition on a Windows 10 machine.
I've tried "using System.Web" but it only seems to contain "AspNetHostingPermission" and friends, no HttpUtility.
You simply need to reference the DLL System.Web, right click References > Add Reference > Assemblies > Framework > System.Web
Also check you're not targeting the Client Profile, in which System.Web.dll is not available. You can target the full framework in Project Properties.
This question already has answers here:
C# using others code
(4 answers)
Closed 5 years ago.
I made a blank solution in C#( without any project ) and I added two Class Library Projects named "PersonLibrary" and "AnotherLibrary". The problem is that when I try to access the PersonLibrary from AnotherLibrary with: "using PersonLibrary;" I get this error: The type or namespace name "PersonLibrary" could not be found.
1
If you go to AnotherLibrary -> References -> Add Reference, you should see an option to add projects in solutions and add PersonLibrary .
Once you add a reference, You can use whatever the available methods.
This question already has answers here:
C# hide and unhide comments
(6 answers)
Closed 9 years ago.
I am using the C# XML style of documentation in my latest project (eg using ///<summary> stuff). I find this makes the source code a pain to read as it just becomes so long. Is there a way in Visual Studio to auto-collapse just these or do I have to use the collapse to definitions and re-expand functions?
Take a look here at the following post, I think it should help
http://www.helixoft.com/blog/archives/30?n=collapse-all-xml-comments-in-vb-net-or-c
This question already has answers here:
Open directory dialog
(16 answers)
Closed 9 years ago.
I have a WPF application that I need to have users access directories in. I have searched to the end of the world on how to integrate windows forms into WPF and have found all kinds of information on how to integrate form controls into my xaml, however, integrating a FolderBrowserDialog.
I am veteran programmer, but very new to .net (2nd day in fact), and I believe I can not find good information on immplementing this simply because I can not determine what the name/type is for a FolderBrowserDialog.
Oh, and I am using c# and Visual Studio 2008
You need to add a reference to System.Windows.Forms.dll, then use the System.Windows.Forms.FolderBrowserDialog class.
Adding using WinForms = System.Windows.Forms; will be helpful.
If I'm not mistaken you're looking for the FolderBrowserDialog (hence the naming):
var dialog = new System.Windows.Forms.FolderBrowserDialog();
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
Also see this SO thread: Open directory dialog