Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created December 8, 2025 19:05
Show Gist options
  • Select an option

  • Save dcomartin/69f42b565ab3b0eb89d70908db41400a to your computer and use it in GitHub Desktop.

Select an option

Save dcomartin/69f42b565ab3b0eb89d70908db41400a to your computer and use it in GitHub Desktop.
public class GroupChat
{
private const int MaxMembers = 100_000;
public Guid Id { get; private set; }
public int MemberCount { get; private set; }
public GroupChat(Guid id)
{
Id = id;
MemberCount = 0;
}
public void AddMember()
{
if (MemberCount >= MaxMembers)
throw new InvalidOperationException("GroupChat is full");
MemberCount++;
}
public void RemoveMember()
{
if (MemberCount == 0)
throw new InvalidOperationException("No members to remove");
MemberCount--;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment