A wake-on-lan packet is simply any network or transport level packet with a certain signature.
The expected signature is:
6 Bytes of a header (set to 0xFF)
16 repetitions of a target MAC Address (6 bytes each)
... for a total of 6 + 6 * 16 = 102 bytes
Note that these are typically sent (broadcasted rather) as a user-datagram (UDP) packet to port 7, or 9.
Here is a very detailed Wiki article: http://en.wikipedia.org/wiki/Wake-on-LAN
If you would like to look at a sample implementation in Go
(I know its not C#, but you can get an idea of how it works), take a look at a magic_packet handler I wrote.
As far as remote power on (physical)
You can explore buying an IP power switch, which you can send a wake / shutdown command to over some managed interface (typically HTTP). These are commercially available and can cost a bit.
I think you can also go the route of building some type of micro-controller which can be triggered via Wifi to manage a relay connected to your PCs power switch. Lots of options :)