How do you set the window resolution for a game?

Calling a console command from a method? How would do you that?

For example, ResX and ResY <— exactly what I want, but I don’t know how to use them at runtime.