Is there a way to “create” a method name?

Okay, this might be bad practice, but I have three methods, Event1, Event2, and Event3.

I want to choose which event to call based on parameters that I'm passing to another function, chooseEvent(int number);

so that if I pass in something like chooseEvent(1), I'll call Event1. Is this possible? I tried doing something like "event"+number(); but that didn't work haha.

by byviolet via /r/csharp

Getting a window to redraw?

I have a separate app that I made a child window of my app via a SetParent(). This causes the other application to shrink and change its height and width(which I want). Strange thing is it makes my UI on it all wonky unless I either hold the mouse down on the title bar for a second, move the form around the screen with the mouse or resize it manually with the mouse.

Is there any way I can do this via code? I have tried using SendMessage with WM_paint and no luck.

by atreyal via /r/csharp

Help with methods, beginner

I am working on a basic loan calculator program. I need to make three methods that feed into a main method with contents of variables and call of methods
GetLoanTerms( );

CalculatePayment( );

DisplayResults( );

How do i set the variables in the first method and make them public to be used in the rest of the program. What I have now is below but I am getting an error calling the variables. How do i ref the variables for the get method into the main method?

static void Main(string[] args) {

 GetLoanTerms( , , ); CalculatePayment(); DisplayResults(); } public double GetLoanTerms (ref double LoanAmt, ref double Interest, double Periods) { Console.WriteLine("Please enter your loan amount."); return LoanAmt = double.Parse(Console.ReadLine ()); Console.WriteLine("Now enter your interest rate."); return Interest = double.Parse(Console.ReadLine()); Console.WriteLine("How many months will you pay the loan over?"); return Periods = double.Parse(Console.ReadLine()); Console.WriteLine("Your inputs are " + LoanAmt + Interest + Periods); } 

by Ifanyonecan via /r/csharp

Need help with a program that creates folders based on the files selected

Basically, I'm trying to make a program that will look into a folder that contains documents like "song1.txt" "song2.txt" "album.txt" "book.txt" and create folders based on their names, therefore a folder for "song, album, book" where each of the respective files are copied to. I want it to also ignore the numbers in the name to keep it in the right, grouped folder, as well as creating new folders for each thing that has no number.
Thus far, what I know how to do is open the folder browser dialog…but as for gathering each file name of each document in the selected folder, I'm not sure of.

by soundofthec via /r/csharp

Resizing another applications or scaling it?

So I have a WFP project and I used SetParent to make a separate application a child of my project. The only issue is I can not get it to scale to the size I want. SetWindowPos doesnt seem to be doing much of anything that i can tell. Is there another way to go about it. Also the child application is not resizable on its own so that could be part of the problem. I dont even necessarily need to resize it as much as scale it down. Any ideas or directions would be awesome, TY.

by atreyal via /r/csharp

Trouble installing Tools for Universal Apps in VS2015 RC


I just installed the VS 2015 Community Edition Release Candidate and wanted to dive into some Universal-Apps development.

If I want to create a new project for universal apps, a download page from microsoft openes and I downloaded the tools. The file is named "VSToolsForWindows.exe".

However, I then get errors while installing: "Tools für universelle Windows 10-Apps (Windows SDK 10.0.10069) : Dieses Produkt wurde nicht erfolgreich heruntergeladen: Gecachte Datei wurde nicht gefunden. "

Translated: Cached file could not be found

I also get those problems with Android SDK and things like that.

I tried to install those tools via the initial setup of VS 2015, but then I got those errors and VS got installed without those features. Then I tried the modify installation, but I got the same error. The third step was this download page which you get to if you try to create a new universal apps project. The fourth thing I tried was to install windows 10 sdk and emulator on my own (was some stackoverflow post), but the emulator setup doesn't work. I also can't create such a project now.

Did anyone run into the same problem?

I'm running Windows 8.1 64bit by the way. I also have enough disk space to install those things.

Thanks in advance!

by Moercy via /r/csharp