fork download
  1. public class MyList<T> {
  2. private T[] data;
  3. private int count;
  4. private int capacity;
  5.  
  6. public MyList() {
  7. capacity = 4;
  8. data = new T[capacity];
  9. count = 0;
  10. }
  11.  
  12. private void Resize() {
  13. capacity *= 2;
  14. T[] newData = new T[capacity];
  15. Array.Copy(data, newData, count);
  16. data = newData;
  17. }
  18.  
  19. public void Add(T item) {
  20. if (count == capacity)
  21. Resize();
  22. data[count++] = item;
  23. }
  24.  
  25. public void PopBack() {
  26. if (count > 0)
  27. count--;
  28. }
  29.  
  30. public void PushFront(T item) {
  31. if (count == capacity)
  32. Resize();
  33. for (int i = count; i > 0; i--)
  34. data[i] = data[i - 1];
  35. data[0] = item;
  36. count++;
  37. }
  38.  
  39. public void PopFront() {
  40. if (count == 0) return;
  41. for (int i = 0; i < count - 1; i++)
  42. data[i] = data[i + 1];
  43. count--;
  44. }
  45.  
  46. public T this[int index] => data[index];
  47. public int Count => count;
  48. }
  49.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Welcome to .NET 6.0!
---------------------
SDK Version: 6.0.100

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Package source with Name: nuget.org disabled successfully.
Package source with Name: local added successfully.
CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/home/V89zcR/Project/Project.csproj]



CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/home/V89zcR/Project/Project.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:03.72
stdout
Standard output is empty