The verb 姓 (xìng) literally means "to be surnamed" or "to have the surname." You can use 姓 to tell someone your own surname, or that of someone else.

Structure
Giving One's Surname

Examples

Wǒ xìnɡ Wánɡ.
我 姓 王。
My last name is Wang.

Asking Someone's Surname
You can also use 姓 to ask people their surnames. You could do this quite directly by saying:

Nǐ xìnɡ shénme ?
你 姓 什么 ?
What is your last name?

However, the polite way to ask has a set form:

Nín ɡuì xìn?
您 贵 姓 ?

Literally this means "What is your honourable surname?" Use this form to be polite when asking people their surnames.
What is your honourable surname?