Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best way to re-factor
Message
De
14/02/2013 12:31:01
 
 
À
14/02/2013 11:31:30
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01565967
Message ID:
01566030
Vues:
61
>>>>>>>It actually also needed closeSalespoint and closeOperator. I sent both as out parameters but I was thinking I may create the above as a class instead with these properties. Do you think it will be a better solution or 4 out parameters is not bad?
>>>>>>
>>>>>>
>>>>>>Dunno - there are several ways
>>>>>>
>>>>>>Viv's personal limit is about 5
>>>>>>Another option mentioned is to have the method return a Tuple - only inconvenience of a tuple is that the properties do not have meaningful names
>>>>>>
>>>>>>Another option suggested is to create a class. I would opt for a private nested class in that case
>>>>>
>>>>>Can you show how the private nested class idea looks like, please?
>>>>>
>>>>It;s just a class declaration within a class.
>>>>
>>>>	class TheClass
>>>>	{
>>>>		public void Work()
>>>>		{
>>>>
>>>>			PrivateClass hello = new PrivateClass();
>>>>
>>>>			hello.DoWork(); // with parameters needed
>>>>			Console.WriteLine("{0} {1}", hello.StartTime, hello.EndTime);
>>>>			Console.ReadLine();
>>>>
>>>>		}
>>>>		private class PrivateClass
>>>>		{
>>>>			public DateTime StartTime { get; private set; }
>>>>			public DateTime EndTime { get; private set; }
>>>>
>>>>			public void DoWork()
>>>>			{
>>>>				StartTime = DateTime.Now;
>>>>				EndTime = DateTime.Now;
>>>>			}
>>>>
>>>>		}
>>>>
>>>>	}
>>>>	
>>>>
>>>
>>>I see, thanks a lot - this may be very useful for me.
>>
>>I don't think it's much of a difference. It's just a different means of accessibility to a class. What's in the class is still the same. You instantiate it the same way and use it the same way. All that changes is where the PM finds it.
>
>Not really true Mike.
>An nested private class in not available outside the class.
>In the above example this would not compile:
>var = new TheClass.PrivateClass().
>It *would* work if the inner class was public.
>


> Also a nested class has access to members of the containing class.....

I think the members of the containing class have to be static - or you need to pass an object reference
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform