Declare a class or struct inside a method June 8, 2023 by Tarik You can create an anonymous type like so: var x = new { x = 10, y = 20 }; but other than that: no.