|
Almost any book would do;
my first C# book was "Microsoft Visual C#.NET step by step" by John Sharp and Jon Jagger (2002),
but that is a bit outdated now, since there is C$ 2.0 now, adding features to the language
so you might want to look for a more recent book.
My first OO experience dates way back, cant even remember.
You may find some book recommendations on one of the CP forums.
And you might want to visit the Amazon site, and look at the hundrads of C# books there.
They come with stars and recommendations too.
But then, in my experience book appreciation is a very subjective matter; it all depends
on prior knowledge, personal style, and your attitude towards the balance between
reading, following a classroom course, and doing your own experiments.
|
|
|
|
|
|
As you can see from your example, Child derives from Base. This means that you can create an instance of Child even if you refer to it by an ancestor class. Now, why is this useful? Consider this design (highly contrived, but it does illustrate the point):
public class Sales
{
private double _salesTax = 1.05;
public double CalculateSale(double basePrice)
{
return basePrice * this.SalesTax;
}
public virtual double SalesTax
{
get { return _salesTax; }
}
}
public class EuSales : Sales
{
public override double SalesTax
{
get { return 1.175; }
}
}
public class ShoppingCart
{
private SaleLines _saleLines = new SaleLines();
public SaleLines Lines
{
get { return _saleLines ; }
set { _saleLines = value; }
}
public double TotalSales(Sales tax)
{
return _salesLine.TotalCost * tax.SalesTax;
}
public class SaleLine
{
public string Item;
public double ItemCost;
public int Qty;
}
public class SaleLines
{
private List<SaleLine> _lines = new List<SaleLine>();
public void AddLine(string item, double cost, int qty)
{
SaleLine line = new SaleLine();
line.Item = item;
line.ItemCost = cost;
line.Qty = qty;
_lines.Add(line);
}
public double TotalCost
{
get
{
double runningTotal = 0.0;
for (int i = 0; i < _lines.Count; i++)
{
runningTotal = _lines[i].Qty * _lines[i].ItemCost;
}
return runningTotal;
}
}
}
} Now, if you create a test harness for this and pass in an instance of Sales to the TotalSales method, you will get the a total multiplied by 1.05. If you pass in an instance of EuSales, you get the total multiplied by 1.175%.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi, I am trying to get the username of the user logged into Windows Server 2003 the followiong code seems to work ok for windows xp but when i use the smae code on Server 2003 the code returns a blank.If anyone has any ideas or suggestions they would be appreciated.....
string user = HttpContext.Current.Request.ServerVariables["LOGON_USER"];
Thanks in advance
Tim
|
|
|
|
|
I managed to solve this by turning off anonymous access in iis
|
|
|
|
|
Hi,
Can anybody tell me how to add support for a new languages without ever recompiling the neutral assembly that contains all the application code.After deploying the application I created a satlite assembly for a new language and uploaded to the bin directory of the application.But if I change the application culture it is not reading the values form the new satlite assembly.
Thanks&Regards,
Prajin
|
|
|
|
|
Please don't cross post. It's not good manners.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
hello C# community,
I am trying to add some very simple graphical components to a GUI that I am building in C#, and I wanted to know if there was a way to do this in VS2005 or natively in C#......
I would like to create horizontal/vertical rules, arrows, circles....all that would have no functionality, but simply make the GUI look nicer....Although I could do this in PS or paint and add them as images, I would like to be able to make simple shapes on the fly....
anyone?
I am who I am because of who everyone around me is.
|
|
|
|
|
If you are running on a pre-Vista OS, then you are going to have to learn GDI+ to do this. Basically, you will need to write code that generates these as images and serve them up to the page "on-the-fly".
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
running XP...so, any starting point suggestions of GDI+....
...the more you learn......
I am who I am because of who everyone around me is.
|
|
|
|
|
Suppose that you want to add a simple circle at the corners of your form. One way to do this would be to create a user control and anchor this at each corner. In the control, you would override the Paint method and draw the circle. For instance:
public override void Paint(Graphics g)
{
using (Pen myPen = new Pen(Color.Red, 2))
{
g.DrawEllipse(myPen, this.Bounds);
}
}
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
wicked...this is more or less what I was looking to do...I'm sure if I mess around with it for a little....
thank you...
I am who I am because of who everyone around me is.
|
|
|
|
|
No problem - glad to help.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Graphics.FromHandle(...);
If you pass the handle of a control (panel eg) you can use the received object to draw on that control.
Most methods in the Graphics Object speak for themself (and there is always MSDN)
hope this helps.
V.
If I don't see you in this world, I'll see you in the next one... And don't be late. (Jimi Hendrix)
|
|
|
|
|
thanks V,
MSDN is where I'll head over to check out the Graphics object....I'm new to C# so any tips are always appreciated.
thx
I am who I am because of who everyone around me is.
|
|
|
|
|
Does anyone know of a C#/.NET telnet component that supports ibm 3151 terminal emulation?
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Hi,
I have 3 quick Vista questions.
The first question, is how can I tell if my program is running on Vista?
(I've run accross the OperatingSystem class and the Environment.OSVersion value in my googling, but I can't find out if this class should be used for Vista, or what values I'd need to look for.)
My second question, is how do I get to the users applications folders?
(I know that they're all in the C:\Users\ folder, but I don't know how to get to a specific users folder.)
My last question is to do with Services in Vista. I need to start a service from my program if it hasn't already been started. However when trying to start it (using the myservice.Start() function) I get a InvalidOperationException. I've been told that this is a security issue with the program, however running the program as administrator doesn't help. Anyone have any clue as to how to get around this problem?
Thanks in advance,
Munty
|
|
|
|
|
We have a Vista board for your questions.
_____________________________________________
Flea Market! It's just like...it's just like...A MINI-MALL!
|
|
|
|
|
Did you read his questions or just fire off the subject? They're all "how do I make my C# program do Foo", not "where in the vista control panel is foo hiding" questions.
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
1. System.Environment.OSVersion.Version.Major > 5
2. Application.LocalUserAppDataPath
3. Use Net start .
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi Pete,
Thanks for the other 2 answers. They're doing what I want them to.
Net Start doesn't work on the Vista machine I have. It gives me an "System Error 5" message.
Just to note, but the "myservice.Start()" and "Net Start "myservice"" works on my XP machine.
Some further information about the service. As long as I start the service from the Services admin tool, it does what I want it to. It's just getting the service started by the program that's the problem. (The program needs the service running in order to work.)
Any ideas?
- Munty
-- modified at 10:29 Monday 23rd July, 2007
|
|
|
|
|
The only other way that I can think to do this would be to use the Service API. This[^] code shows the C++ equivalent of what you want to do.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Adding to what Pete said,
NT is known as 5.0, XP is 5.1 and Vista is 6.0
(the next big client OS will be 7.0)
|
|
|
|
|
Hi Guys,
Thanks for the answers. I'm going to test them out now.
- Munty
|
|
|
|
|
Hi all,
I have a listview and in this i m moving items up and down but when i move up or down
an item it still remains the previous selection.
how can i remove my previous selection?
Praveen Sharma
|
|
|
|