📖 About C#
C# is a modern, object-oriented programming language that combines the power of C++ with the simplicity of Visual Basic. It's the primary language for .NET development and excels at building enterprise applications, web services, and desktop software.
🎯 Best For
- Enterprise applications
- Web APIs with ASP.NET Core
- Desktop applications (WPF, WinForms)
- Game development with Unity
- Cloud services and microservices
🔧 Key Features
- Records for immutable data types
- Nullable reference types for null safety
- Pattern matching for control flow
- async/await for asynchronous programming
- LINQ for data querying
- Dependency injection built-in
🛠️ Development Tools
Build
dotnet build
Test
dotnet test
Coverage
dotnet test /p:CollectCoverage=true
Run
dotnet run
📄 Package Contents (7 files)
AGENTS_RULES.md
Complete AI agent rules (universal)
- CSHARP-specific best practices
- TDD workflow (Red-Green-Refactor)
- DDD principles and patterns
- Git workflow and commit format
- Code quality principles
.cursorrules
Quick reference for Cursor IDE
- Essential rules summary
- Links to full documentation
- Optimized for quick loading
.gitignore
Git exclusions
- CSHARP-specific patterns
- Build artifacts
- IDE configuration files
- Dependency directories
AGENTS.md
Quick reference guide
- Common patterns
- Best practices summary
- Quick troubleshooting
README.md
Project template with examples
- Setup instructions
- Sample code and structure
- Testing examples
- Build and run commands
CODE_QUALITY_PRINCIPLES.md
Quality principles and best practices
- Avoid default values (fail-fast)
- Consistency across code paths
- Extract reusable functions
- CSHARP-specific examples
CONTRIBUTING.md
Contribution guidelines
- TDD workflow (Red-Green-Refactor)
- Git commit format
- Code review process
- Testing requirements (90% coverage)
💻 Code Examples
Record Types
public record User(string Name, string Email, int Age);
var user = new User("John", "john@example.com", 30);
var updated = user with { Age = 31 };
Pattern Matching
var result = value switch
{
> 0 => "Positive",
< 0 => "Negative",
0 => "Zero",
_ => "Unknown"
};
Nullable Reference Types
public class UserService
{
public User? FindUser(string email)
{
// Compiler enforces null checks
return users.FirstOrDefault(u => u.Email == email);
}
}