i'm working with PHP code and i have not much experienced with C#, i modified my code a lot, but still experiencing error "A field initializer cannot reference the non-static field, method, or property" at line number 34 Why it happens always and how to fix it?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Finisar.SQLite;
namespace Stemmer
{
class ValueObj
{
public void postfix(string table)
{
SQLiteConnection sqlite_conn;
SQLiteCommand sqlite_cmd;
SQLiteDataReader sqlite_datareader;
sqlite_conn = new SQLiteConnection("Data Source=database.db;Version=3;New=False;Compress=True;");
sqlite_conn.Open();
sqlite_cmd = sqlite_conn.CreateCommand();
sqlite_cmd.CommandText = "SELECT * FROM " + table;
sqlite_datareader = sqlite_cmd.ExecuteReader();
List<string> list = new List<string>();
while (sqlite_datareader.Read())
{
list.Add(sqlite_datareader.GetString(1));
}
return list.ToArray(); // returns void, a return keyword must not be followed by an object expression
}
public string[] postfixList = postfix("postfixList"); // A field initializer cannot reference the non-static field, method, or property
}
}