我已經瀏覽了這裏的幾篇文章,並且沒有找到我找到的解決方案。我嘗試從窗體a傳遞一個對象到窗體b,當你點擊一個菜單項時,它給了我錯誤:不一致性可訪問性:參數類型
錯誤1不一致的可訪問性:參數類型'WindowsFormsApplication1.character'比方法'WindowsFormsApplication1.CharBuilder.CharBuilder(WindowsFormsApplication1.character)'
這裏爲發送形式:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class GVL4 : Form
{
public GVL4()
{
InitializeComponent();
}
public void mNewGame_Click(object sender, EventArgs e)
{
character MyCharacter = new character();
MyCharacter.SetIsNew();
CharBuilder NewCharacter = new CharBuilder(MyCharacter);
NewCharacter.Show();
}
}
}
和接收形式:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class CharBuilder : Form
{
character Char = new character();
public CharBuilder()
{
InitializeComponent();
}
//Overloaded Constructor
public CharBuilder(character cChar)
{
Char = cChar;
}
private void txtSect_TextChanged(object sender, EventArgs e)
{
}
private void btnSaveID_Click(object sender, EventArgs e)
{
if (Char.IsNew())
{
Char.SaveCharIdentity(txtCharName.Text, txtClan.Text, txtSect.Text, txtNature.Text, txtDemeanor.Text, txtTitle.Text, txtCoterie.Text, txtSire.Text, txtPlayerName.Text, txtCharacterID.Text, txtStatus.Text, Convert.ToInt32(txtUnspentXP.Text), Convert.ToInt32(txtEarnedXP.Text), Convert.ToInt32(txtGeneration.Text), Convert.ToInt32(txtBloodPool.Text), cbxNPC.Checked);
}
txtTestBox.Text = Char.ToString();
}
public void CharBuilder_Load(object sender, EventArgs e)
{
}
}
}
的錯誤是在重載(公共CharBuilder(字符CCHAR))
發佈定義您的角色類的代碼,這是問題的可能來源。 –