Do i have to assign an ip from the same class to the virtual sw?
Assign addresses based on the network the external vSwitch is plugged into
Is the virtual sw ip the gateway for VM?
Not exactly. When you create a new external vSwitch the internet protocols are removed from the adapter and the Hyper-V Extensible Switch protocol is added turning that physical port into a multi-port virtual switch. Connect your VMs to this vSwitch and use each VM's vEthernet to configure the addressing in the exact same manner as if it were a physical NIC
--please don't forget to upvote
and Accept as answer
if the reply is helpful--