I have a C# file A which defined some public enum and public struct. Now I need to define errorCode for them. I defined an enum named SubsystemErrorCode in file B. Both A and B don’t have class inside. They are in the same namespace In one struct of file A, I try to use the SubsystemErrorCode enum but it give me error tell me :
Error 1 The type or namespace name ‘SubsystemErrorCode’ could not be found (are you missing a using directive or an assembly reference?)
If I move that SubsystemErrorCode into the same file. no error. But I really want them to be separated. How can I do this? thanks,
File A:
namespace SystemSoftware {
public struct StatusMessageBody {
public ProcessControlStatus State;
public StatVal LVP_OK;
public SubsystemErrorCode LVP_ERROR_CODE;
}
}
File B:
namespace SystemSoftware
{
//public class ErrorCode
//{
public enum SubsystemErrorCode : byte
{
NoError = 0,
EPCSS_CPU_ERROR = 1,
LVPS_ERROR
}
//}
}
Change your enum file to this
and in your File A put this up the top (under
using System;)or you could asl try in File A
instead of
Edit: Forgot to say, I’m assuming that both File A and File B are in the same project?
If not, you will need a reference in Project A, to Project B
Ok Edit Again.
I Created Two Files, like you say, in the same project. It works, here they are.
File1.cs
File2.cs