- add GBaseKey class that is only settable once

master
Simon G 5 years ago
parent 168823cfde
commit e29b7cbafd
  1. 30
      GBase/GBaseKey.cs

@ -0,0 +1,30 @@
// Author: Gockner, Simon
// Created: 2020-11-13
// Copyright(c) 2020 SimonG. All Rights Reserved.
using System;
namespace GBase
{
public class GBaseKey
{
private int _key = -1;
private bool _isSet;
public int Key
{
get => _key;
internal set
{
if (_isSet)
throw new InvalidOperationException("Key is already set.");
_key = value;
_isSet = true;
}
}
public override string ToString() => $"{Key}";
public static implicit operator int(GBaseKey key) => key.Key;
}
}
Loading…
Cancel
Save