ILikeCats!
ILikeCats!
CC#
Created by ILikeCats! on 7/1/2024 in #help
2 error abt variables
details: VS 2022, FILE: form1.cs errors: ```Severity Code Description Project File Line Suppression State Error (active) CS0236 A field initializer cannot reference the non-static field, method, or property 'Form1.savepath2' excelbetter C:\Users(user hidden for pivacy)\source\repos\excelbetter\excelbetter\Form1.cs 8

### error 2:

### error 2:
Severity Code Description Project File Line Suppression State Error (active) CS0236 A field initializer cannot reference the non-static field, method, or property 'Form1.workingFile' excelbetter C:\Users\nuh uh\source\repos\excelbetter\excelbetter\Form1.cs 9
var names for errors `workingFile`, `savepath2`
### code \\/
var names for errors `workingFile`, `savepath2`
### code \\/
using ClosedXML.Excel; namespace excelbetter { public partial class Form1 : Form { public string savepath2 = @"C:\Users\nuh uh\excel" + "YIPPE.xlsx"; public XLWorkbook workingFile = new XLWorkbook(savepath2); public IXLWorksheet spreadsheet1 = workingFile.AddWorksheet("s"); public Form1() { InitializeComponent(); } public void process_Data_Click(object sender, EventArgs e) { Close(); } } } ```
13 replies