Bronya
Bronya
CC#
Created by Bronya on 9/13/2024 in #help
How to make this Field into Property
public class MyColumn
{
public List<string> Data { get; set; }
public int Count => Data.Count;

public MyColumn()
{
Data = new List<string>();
}
}
public class MyColumn
{
public List<string> Data { get; set; }
public int Count => Data.Count;

public MyColumn()
{
Data = new List<string>();
}
}
anyone know how to make public int Count => Data.Count; into property?
4 replies
CC#
Created by Bronya on 9/12/2024 in #help
thinking how my code should look like
using System;
using static MyFunction.Function1;

public class Program
{
public static void Main(string[] args)
{
string readFilePath = "CSVReadFilePath";
string writefilePath = "CSVWriteFilePath";

CSVData csvData = new CSVData();
csvData.ReadCSV(readFilePath);

Func1(csvData);
Func2(csvData);
Func3(csvData);
//Func4, 5, 6, 7, 8, 9, and so on

csvData.WriteCSV(writefilePath);
}
}
using System;
using static MyFunction.Function1;

public class Program
{
public static void Main(string[] args)
{
string readFilePath = "CSVReadFilePath";
string writefilePath = "CSVWriteFilePath";

CSVData csvData = new CSVData();
csvData.ReadCSV(readFilePath);

Func1(csvData);
Func2(csvData);
Func3(csvData);
//Func4, 5, 6, 7, 8, 9, and so on

csvData.WriteCSV(writefilePath);
}
}
On other file: (there will be multiple files like this)
using System;

namespace MyFunction
{
public class Func1Field
{
public CSVData csvData { get; set; }
public decimal Field1 { get; set; }
public decimal Field2 { get; set; }
// only properties exist in this class, lots of properties!
}
public static class Function1
{
// this class have no field or property
private static void Method1(ref Func1Field field) {/*code*/}
private static void Method2(ref Func1Field field) {/*code*/}
// only one public method exist in this class
public static void Func1(ref Func1Field field)
{
//code
Method1(field);
//code
Method2(field);
//code
}
}
}
using System;

namespace MyFunction
{
public class Func1Field
{
public CSVData csvData { get; set; }
public decimal Field1 { get; set; }
public decimal Field2 { get; set; }
// only properties exist in this class, lots of properties!
}
public static class Function1
{
// this class have no field or property
private static void Method1(ref Func1Field field) {/*code*/}
private static void Method2(ref Func1Field field) {/*code*/}
// only one public method exist in this class
public static void Func1(ref Func1Field field)
{
//code
Method1(field);
//code
Method2(field);
//code
}
}
}
what do you guys think of this idea? is this a good structure?
39 replies