Click here to Skip to main content
15,881,380 members
Home / Discussions / C#
   

C#

 
GeneralRe: What is the correct code to invoke subscribers for an event? Pin
BillWoodruff24-Jul-16 23:04
professionalBillWoodruff24-Jul-16 23:04 
GeneralRe: What is the correct code to invoke subscribers for an event? Pin
Richard Deeming25-Jul-16 0:05
mveRichard Deeming25-Jul-16 0:05 
GeneralRe: What is the correct code to invoke subscribers for an event? Pin
User 1106097925-Jul-16 0:30
User 1106097925-Jul-16 0:30 
SuggestionRe: What is the correct code to invoke subscribers for an event? PinPopular
Maarten197725-Jul-16 3:16
Maarten197725-Jul-16 3:16 
GeneralRe: What is the correct code to invoke subscribers for an event? Pin
User 1106097925-Jul-16 3:58
User 1106097925-Jul-16 3:58 
QuestionTime of action in [Date] [Time] [Action] Pin
mmiklauz23-Jul-16 10:01
mmiklauz23-Jul-16 10:01 
AnswerRe: Time of action in [Date] [Time] [Action] Pin
Mycroft Holmes23-Jul-16 14:20
professionalMycroft Holmes23-Jul-16 14:20 
AnswerRe: Time of action in [Date] [Time] [Action] Pin
BillWoodruff23-Jul-16 15:41
professionalBillWoodruff23-Jul-16 15:41 
Why don't you modify the 'createCar Method in the 'Car class. Example:
C#
public class Car
{
    public void createCar(string carname)
    {
        var dt = DateTime.Now;

        Console.WriteLine("\nCar {0} created at: {1} {2}", carname, dt.ToShortDateString(), dt.ToShortTimeString());
    }
}
If you need to keep track of all the 'Cars created by manufacturer, consider using another class (static ?) that maintains a collection of 'Cars. Or, you could use a static Dictionary<string, List<DateTime>> in the 'Car class.
C#
public class Car
{
    public static Dictionary<string, List<DateTime>> ManufacturerToCars = new Dictionary<string, List<DateTime>>();
    
    public void createCar(string carname)
    {
        var dt = DateTime.Now;
    
        if(! ManufacturerToCars.ContainsKey(carname))
        {
            ManufacturerToCars.Add(carname, new List<DateTime>());
        }
    
        ManufacturerToCars[carname].Add(dt);
    
        Console.WriteLine("\nCar {0} created at: {1} {2}", carname, dt.ToShortDateString(), dt.ToShortTimeString());
    }
}

«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008

QuestionSave Physical File using MySQL Pin
Jassim Rahma22-Jul-16 23:29
Jassim Rahma22-Jul-16 23:29 
AnswerRe: Save Physical File using MySQL Pin
OriginalGriff23-Jul-16 0:31
mveOriginalGriff23-Jul-16 0:31 
GeneralRe: Save Physical File using MySQL Pin
Jassim Rahma23-Jul-16 7:19
Jassim Rahma23-Jul-16 7:19 
GeneralRe: Save Physical File using MySQL Pin
Pete O'Hanlon23-Jul-16 7:49
mvePete O'Hanlon23-Jul-16 7:49 
GeneralRe: Save Physical File using MySQL Pin
Mycroft Holmes23-Jul-16 14:25
professionalMycroft Holmes23-Jul-16 14:25 
QuestionHow to send Images in notification in Android using C#! Pin
Member 1158380322-Jul-16 3:23
Member 1158380322-Jul-16 3:23 
AnswerRe: How to send Images in notification in Android using C#! Pin
Ravi Bhavnani25-Jul-16 5:40
professionalRavi Bhavnani25-Jul-16 5:40 
Questionx86 and x64 in one project Pin
po_saa21-Jul-16 21:33
po_saa21-Jul-16 21:33 
AnswerRe: x86 and x64 in one project Pin
Rob Philpott21-Jul-16 21:46
Rob Philpott21-Jul-16 21:46 
GeneralRe: x86 and x64 in one project Pin
po_saa21-Jul-16 22:15
po_saa21-Jul-16 22:15 
AnswerRe: x86 and x64 in one project Pin
Richard MacCutchan21-Jul-16 21:52
mveRichard MacCutchan21-Jul-16 21:52 
GeneralRe: x86 and x64 in one project Pin
po_saa21-Jul-16 22:11
po_saa21-Jul-16 22:11 
GeneralRe: x86 and x64 in one project Pin
Richard MacCutchan21-Jul-16 22:21
mveRichard MacCutchan21-Jul-16 22:21 
AnswerRe: x86 and x64 in one project Pin
Pete O'Hanlon21-Jul-16 22:05
mvePete O'Hanlon21-Jul-16 22:05 
GeneralRe: x86 and x64 in one project Pin
po_saa21-Jul-16 22:13
po_saa21-Jul-16 22:13 
GeneralRe: x86 and x64 in one project Pin
OriginalGriff21-Jul-16 22:32
mveOriginalGriff21-Jul-16 22:32 
GeneralRe: x86 and x64 in one project Pin
po_saa21-Jul-16 23:19
po_saa21-Jul-16 23:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.