LeetCode: Insert delete getrandom o1 C#
The HashSet&lt;int&gt; won't be changed hence make it readonly.
Instead of calling Contains() prior to the call to Add(), if this evaluates to false, can be simplified to just return _set.Add(val); because the Add() method returns false if the value is allready in the HashSet. Reference
Instead of calling Contains() prior to calling Remove() can be simplified as well to just return _set.Remove(val); because Remove() will return false if the item isn't in the HashSet. Reference
Calling GetRandom() in repeatedly short order  may result in the same element because the Seed of a created Random in .NET framework is based on the current timestamp. It is better to create a class-level Random to be used.

Summing up leads to
public class RandomizedSet {
    
    private readonly HashSet&lt;int&gt; _set;
    /** Initialize your data structure here. */
    public RandomizedSet()
    {
        _set = new HashSet&lt;int&gt;();
    }

    /** Inserts a value to the set. Returns true if the set did not already contain the specified element. */
    public bool Insert(int val)
    {
        return _set.Add(val);
    }

    /** Removes a value from the set. Returns true if the set contained the specified element. */
    public bool Remove(int val)
    {
        return _set.Remove(val);
    }

    private readonly Random rand = new Random();
    /** Get a random element from the set. */
    public int GetRandom()
    {
        int key = rand.Next(_set.Count);
        return _set.ElementAt(key);
    }
}