I get this problem but don’t know how to fix it. I don’t like to change namespace. This is my code:
namespace ParlayRMS.Models.System
{
using System;
using System.Globalization;
public class MaintenanceInfo
{
public MaintenanceInfo()
{
IsDownTime = false;
TimeFrom = DateTime.Now.ToString(CultureInfo.InvariantCulture);
TimeTo = DateTime.Now.ToString(CultureInfo.InvariantCulture);
}
public bool IsDownTime { get; set; }
public string TimeFrom { get; set; }
public string TimeTo { get; set; }
}
}
This class causes error: “Type or namespace ‘DateTime’ could not be found.” because this class is put in namespace System which same as with .NET Framework. If I change “ParlayRMS.Models.System” to “ParlayRMS.Models”, this class will be ok but I don’t like this way. I need a solution for this case without changing many codes.
THanks.
The
Systeminusing System.Globalizationis referring to you namespace, so it should be another compile error there.If you really like the
usings within the namespace (a practice that I, personally, dislike), you should use theglobal::extern alias (I think that’s what it’s called)