SuperJediMedia Posted September 21, 2014 Share Posted September 21, 2014 Public default constructor method that initializes properties about with a the CurrentDate and 2 Zeroes? Link to comment Share on other sites More sharing options...
0 firey Posted September 23, 2014 Share Posted September 23, 2014 Thanks, I am a pretty new to C#... so what's easy to you I don't know well yet. :/ Another question, if any of you would kindly answer. For a public void method say public void xyz() it wants to public void xyz( object abc) as a method. This method casts the object as an abc and adds it to the abc collection. How do I go about do this? So something like: List<abcObj> abcObjs = new List<abcObj>(); private void addToAbcObj(object myObj) { abcObjs.Add((abcObj)myObj); } Link to comment Share on other sites More sharing options...
0 Eric Veteran Posted September 21, 2014 Veteran Share Posted September 21, 2014 What language and what are the two zeros for? Link to comment Share on other sites More sharing options...
0 +theblazingangel MVC Posted September 21, 2014 MVC Share Posted September 21, 2014 Do you know what a constructor is? Do you know what class properties are? Do you know how to set the value of a property? How much experience do you have with programming? This is a pretty simply thing to do; please post what you've tried / know so far and then ask some more in depth questions about what exactly you're not understanding or otherwise having trouble with. Link to comment Share on other sites More sharing options...
0 simplezz Posted September 21, 2014 Share Posted September 21, 2014 Public default constructor method that initializes properties about with a the CurrentDate and 2 Zeroes? You mean something like this: import java.util.Date; class MyApp { public static void main ( String[] args ) { DateStore currentDate = new DateStore (); System.out.println ( currentDate.getDate () ); } } class DateStore { private Date date; public DateStore () { this.date = new Date (); } public String getDate () { return date.toString (); } } $ javac class.java $ java MyApp Sun Sep 21 20:43:34 BST 2014 Not sure what you mean by "2 Zeroes". Richard Grant 1 Share Link to comment Share on other sites More sharing options...
0 SuperJediMedia Posted September 21, 2014 Author Share Posted September 21, 2014 C# Link to comment Share on other sites More sharing options...
0 +Majesticmerc MVC Posted September 21, 2014 MVC Share Posted September 21, 2014 C# We need more description what you're class looks like. You can use DateTime.Now to get the current date and assign it to a class member, and assuming that you want the "zeroes" to be assigned to integer variables, just do something like this: myInt = 0; Link to comment Share on other sites More sharing options...
0 Squirrelington Posted September 21, 2014 Share Posted September 21, 2014 public class MyClass { public int Integer1 { get; set; } public int Integer2 { get; set; } public DateTime DateTime1 { get; set; } public MyClass() { this.Integer1 = 0; this.Integer2 = 0; this.DateTime1 = DateTime.Now; } } C# Link to comment Share on other sites More sharing options...
0 SuperJediMedia Posted September 22, 2014 Author Share Posted September 22, 2014 Thanks, I am a pretty new to C#... so what's easy to you I don't know well yet. :/ Another question, if any of you would kindly answer. For a public void method say public void xyz() it wants to public void xyz( object abc) as a method. This method casts the object as an abc and adds it to the abc collection. How do I go about do this? Link to comment Share on other sites More sharing options...
0 +virtorio MVC Posted September 22, 2014 MVC Share Posted September 22, 2014 That's more cryptic than your first request. Link to comment Share on other sites More sharing options...
0 +theblazingangel MVC Posted September 22, 2014 MVC Share Posted September 22, 2014 That's more cryptic than your first request. Yep; sounds like someone trying to get us to do their homework to me OP, if you're genuinely just trying to learn, that's fine, I'm happy to help, but I'm not convinced that's the case, and you're not framing your questions well. For this last question of yours, post the code you've got so far and then maybe we can demonstrate and explain how best to achieve what you're after. +virtorio and Dick Montage 2 Share Link to comment Share on other sites More sharing options...
0 Krome Posted September 23, 2014 Share Posted September 23, 2014 lol you guys are doing his homework for sure... :p Link to comment Share on other sites More sharing options...
0 SuperJediMedia Posted October 3, 2014 Author Share Posted October 3, 2014 Thanks! @Squirrelington @Riva, @firey, @simplezz Link to comment Share on other sites More sharing options...
Question
SuperJediMedia
Public default constructor method that initializes properties about with a the CurrentDate and 2 Zeroes?
Link to comment
Share on other sites
12 answers to this question
Recommended Posts