无论我怎么努力,我总是会收到这个可怕的“对象引用未设置为对象实例”的错误。我是C#的新手,绝对感到困惑。任何帮助将不胜感激
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace n00bSwapper
{
/// <summary>
/// Interaction logic for MenuWindow.xaml
/// </summary>
public partial class MenuWindow : Window
{
long[] o { get; set; }
byte[][] r { get; set; }
String[] p { get; set; }
long[] offsets = new long[0];
byte[][] replaces = new byte[0][];
String[] paks = new String[0];
long[] a = new long[] { };
byte[][] b = new byte[][] { };
String[] c = new String[] { };
public int count = 0;
public static void ReplaceBytes(string pak, long offset, byte[] bytes)
{
BinaryWriter binaryWriter = new BinaryWriter((Stream)File.Open(pak, FileMode.Open, FileAccess.ReadWrite));
binaryWriter.BaseStream.Seek(offset, SeekOrigin.Begin);
binaryWriter.Write(bytes);
binaryWriter.Close();
}
public MenuWindow(String type, String have, String want, long[] a, byte[][] b, String[] c)
{
InitializeComponent();
HP.Source = new BitmapImage(new Uri(@"/images/" + type + "s/" + have + ".png", UriKind.Relative));
WP.Source = new BitmapImage(new Uri(@"/images/" + type + "s/" + want + ".png", UriKind.Relative));
}
private void Convert(object sender, RoutedEventArgs e)
{
foreach (String pakFile in c)
{
Console.Text += pakFile + "\n";
}
Console.Text += "[LOG] Done!\n";
}
}
}
我现在的最终目标只是使Convert方法/函数中的代码起作用(idk叫它,它是按钮按下的事件监听器)可以工作-我希望它遍历每个项目并将带有该项值的行添加到控制台文本框中。