How do I get the default constructor value in a function
Posted
by
lax
on Stack Overflow
See other posts from Stack Overflow
or by lax
Published on 2012-10-14T09:29:52Z
Indexed on
2012/10/14
9:37 UTC
Read the original article
Hit count: 202
c#
|default-constructor
public class AppXmlLogWritter
{
public int randomNumber;
public string LogDateTime = "";
public AppXmlLogWritter()
{
Random random = new Random();
randomNumber = random.Next(9999);
LogDateTime = DateTime.Now.ToString("yyyyMMdd HHmmss");
}
public AppXmlLogWritter(int intLogIDPrefix, string strLogApplication, string strLogFilePath)
{
LogIDPrefix = intLogIDPrefix;
LogApplication = strLogApplication;
LogFilePath = strLogFilePath;
}
public void WriteXmlLog(string LogFlag)
{
string value=LogDateTime + randomNumber;**//Here i m getting 0 no date time and random number generated**
}
}
AppXmlLogWritter objParameterized = new AppXmlLogWritter(1234, "LogApplication", "LogFilepath");
AppXmlLogWritter objParmeterlessConstr = new AppXmlLogWritter();
objParameterized.WriteXmlLog("0", "LogFlag");
How do I get the default constructor value in this function?
© Stack Overflow or respective owner