想知道何时在C#中使用嵌套类是正确的?我们是否有使用它的事件是不合理的,因此不正确?
如果你能给出两种情况的例子谢谢
您好C#编程新手.
我一直试图以这种方式投射:
m_GameBoard = new Board((short)i_array[1]); // (i_array is defined as object[] i_array)
Run Code Online (Sandbox Code Playgroud)
编译器没有说什么,但在运行时遇到以下崩溃:
System.InvalidCastException未处理 Message = Association指定无效.Source = B11 Ex02 StackTrace:ב-B11_Ex02.Game..ctor(Object [] i_array)ב-..\B11 Ex02\Game.cs:line 32ב-B11_Ex02.Program.Main()ב-\ B11 Ex02\Program .cs:line 56ב-System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly,String [] args)ב-System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args)ב-Microsoft.VisualStudio.HostingProcess.HostProc. RunUsersAssembly()ב-System.Threading.ThreadHelper.ThreadStart_Context(Object state)ב-System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean ignoreSyncCtx)ב-System.Threading.ExecutionContext.Run(ExecutionContext executionContext ,ContextCallback回调,对象状态)ב-System.Threading.ThreadHelper.ThreadStart()InnerException:
非常感谢您的帮助,提前致谢