I'm going to go ahead and post my code because I think there are a few things I think are important to note:
0) Your instructor is apparently not preparing you adequately to do the assignments. If you have to go to a programming web site like CodeProject for help with a homework assignment, that tells me that part of your problem is that you're not getting the necessary instruction.
1) You need to teach yourself to use google to find the answers. This means you have to construct your search queries adequately so that you get appropriate search results. I recognize that this can be somewhat tedious, especially when you don't know what something is called, but as you progress, you'll learn better terms to include in your search. I pretty much live on google because there's simply too much info to hold in my head.
2) Do not start off thinking about how something done in .Net is "harder" to do than in python. It's just different, and that's to be expected. C# apps are statically compile, whereas Python is a scripting language. There's really no logical comparison that can be made beyond that point.
Anyway, here's the code I came up with. When you remove all the comments, it comes down to just nine lines of code. If you drop it into the
main()
method in a new a console app, and then add
Console.ReadKey();
after this block of code, you'll see it work.
int maxWidth = 15;
int starCount = 1;
int increment = 2;
while (starCount >= 1)
{
Console.WriteLine(string.Concat(new string('-', (int)((Math.Abs(maxWidth)-starCount)/2)), new string('*', starCount)));
increment = (increment == 2 && starCount < Math.Abs(maxWidth)) ? 2 : -2;
starCount = starCount+increment;
};