Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should a c# class generate instances of itself?

I have a class that defines a CallRate type. I need to add the ability to create multiple instances of my class by reading the data from a file.

I added a static method to my class CallRate that returns a List<CallRate>. Is it ok for a class to generate new instances of itself by calling one of its own constructors? It works, I just wonder if it's the proper thing to do.

List<CallRates> cr = CallRates.ProcessCallsFile(file);
like image 996
user10178 Avatar asked Nov 02 '08 00:11

user10178


People also ask

What should I set my AC at when working?

Air conditioners are at their top performance when they're running at full-blast, but you don't want your system to be doing its best work when no one is around to enjoy the refreshing coolness. Instead of turning the whole system off when you leave, set your thermostat to around 78 degrees.

What settings should my AC be on?

Start by setting your thermostat higher than normal when you are away, and at 78 degrees when you are home. That is the Department of Energy's recommended setting when you need cooling, but want to save energy.

Does turning your AC up during the day save money?

Your AC will actually run longer overall if it is left on all day instead of being shut off. If you turn it off for part of the day, it runs less and results in more energy savings for you. In almost all cases, it will save you money to shut off your AC while you are away from home.

Is 70 degrees good for AC?

If you want to feel good, as in comfortable, many people will want to lower their thermostat to the low 70s in summer. But if you're talking about saving money on energy and limiting your environmental impact, 70 degrees Fahrenheit is a very bad temperature for your AC to reach.


1 Answers

It is perfectly fine to get object(s) of its own from the static method.

e.g.

One of the dot net libraries does the same thing as you did,

XmlReadrer reader = XmlReader.Create(filepathString);
like image 125
Ray Lu Avatar answered Sep 28 '22 08:09

Ray Lu