Need help creating a function - C#