Originariamente inviato da alka
Il metodo statico va nella classe stessa da creare.
Purtroppo non ho il tempo materiale di produrre un esempio ora.
Hai dato un'occhiata a quanto ti ho suggerito? (Singleton)
fatto (non avevo dato una occhiata..):
codice:
using System;
using System.Collections.Generic;
using System.Text;
namespace SpaRiscFatt
{
class UserLevel
{
private int m_Level;
private static UserLevel instance;
public UserLevel(int Valore)
{
m_Level = Valore;
}
public UserLevel(){}
public static UserLevel GetInstance()
{
if (instance == null)
{
instance = new UserLevel();
}
return instance;
}
public int Valore
{
get
{
return m_Level;
}
set
{
m_Level = value;
}
}
}
}
thanx mille