Passing auto properties as ref
The C# compiler doesn't allow this. What's the reason for this? And what workaround I can use? Basically I need to swap some values around, but don't wanna have the same swapping code all over. ...
The C# compiler doesn't allow this. What's the reason for this? And what workaround I can use? Basically I need to swap some values around, but don't wanna have the same swapping code all over. ...
Hi I am using Visual Studios 2008 Express so I am wondering if there is a 3rd party standalone app that I can use to make my C# snippets fast and easy(gui interface) and then somehow upload it into my VS2008. I am not sure what snippets are held in but I want to keep backups of them. I am not sure if Visual Studios has an import snippe...
I am new to repository pattern but i tried, my goal is to make a design which will let me easily with just some few edits "dependency injection, or configuration edits" to be able to switch to another ORM without touching other solution layers. I reached this implementation: and here is the code: public interface IRepository<T> { T ...
Usually my application sends email with a generic system address. But in some cases I want to instead send as the logged in user. web.config: <?xml version="1.0"?> <configuration> ... <appSettings> ... <add key="DefaultEmailAddress" value="[email protected]" /> </appSettings> <system.net>...
I've seen the simple example of the .net Aggregate function working like so: string[] words = { "one", "two", "three" }; var res = words.Aggregate((current, next) => current + ", " + next); Console.WriteLine(res); How could the 'Aggregate' function be used if you wish to aggregate more complex types? For example: a class with 2 proper...
Hello, I am trying to write a simple internal app with some simple authentication. I'm also trying to make this quick and learn about the forms authentication via web.config. So i have my authentication working if I hard code my 'user name' and 'password' into C# code and do a simple conditional. However, I'm having a tough time stori...
At runtime, if a referenced assembly fails to load with e.g. "Strong name validation failed" (because it's test-signed), is there a way to provide a substitution assembly from another path that is real-signed? I tried subscribing to AppDomain.CurrentDomain.AssemblyResolve, but it doesn't get fired, because the "bad" assembly technically...
The title says it all... ...
I am working with a system that uses GUIDs as keys in most database tables. The guids are created using UuidCreateSequential, in order to be nice to the database indexes. C++ syntax, according to http://msdn.microsoft.com/en-us/library/aa379322%28VS.85%29.aspx : RPC_STATUS RPC_ENTRY UuidCreateSequential( UUID __RPC_FAR *Uuid ); p...
What prompted this question: I'm trying to change the account under which a windows service runs. I decided to use the win32 api rather than WMI and started looking at ChangeServiceConfig. I thought I could simply use the SecureString type in the unmanaged method signature and it would work fine. Hmmm, not quite. This made me wonder,...
Hi, I am making an installer using "setup" project in VS2005. I want the project output - application.exe to be added to startup by modifying this registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run. How can I do in the setup project.Thanks ...
Is the directorysearcher findall results method capped at 5000 results even if pagesize is set to greater. It really seems to be, because no matter what I get exactly 5000 results. This is C# ...
I have the following problem: I want to be able to tell if my application window is the foreground window in Windows. I am using C#, .Net Framework 3.5 on Windows XP. I actually can think of two ways to do what I am after Use pinvoke, GetForeGroundWindow and compare the returned hWnd to the hWnd of my form Check if Form.ActiveForm is ...
I can do a nice cloud effect in flash. I want to do the same in .net 3.5 WPF in C# code. Can you show me how to do it? ...
Hi! What's the best way to create multi-line string in C#? I know the following methods: Using StringBuilder var result = new StringBuilder().AppendLine("one").AppenLine("two").ToString() looks too verbose. Using @ var result = @"one two" looks ugly and badly formatted. Do you know better ways? ...
So I just was testing the CLR Profiler from microsoft, and I did a little program that created a List with 1,000,000 doubles in it. I checked the heap, and turns out the List<> size was around 124KB (I don't remember exactly, but it was around that). This really rocked my world, how could it be 124KB if it had 1 million doubles in it? An...
I'm building a tool in managed code (mostly C++/CLI) in two versions, a 'normal user' version and a 'pro' version. The fact that the core code is identical between the two versions has caused me a little trouble as I want to package the resulting tool as a single assembly (DLL) and I don't want to have to include the .cpp files for the...
I was recently given the following piece of code as a sort-of puzzle to help understand Polymorphism and Inheritance in OOP - C#. // No compiling! public class A { public virtual string GetName() { return "A"; } } public class B:A { public override string GetName() { return "B"; } } ...
Has anyone run an exe using cron job? I want to run an exe at scheduled intervals on a cloud server. The scheduled exe is created using .NET. The cloud server has facility of running Cron jobs using ruby, php, perl, python and http I do not have much knowledge of what a cron job is. What would be the best way of scheduling the EXE? It...
Is it specific to the Banshee project or to the Mono platform as a whole? ...