How to convert String to byte

I want convert String to byte

Ex 0xff on String to 0xff on byte

void setup() {
Serial.begin(9600);
}

void loop() {
byte b =0xff;
String w = String(b,BIN);
String x = String(b,OCT);
String y = String(b,DEC);
String z = String(b,HEX);
Serial.println(b);
Serial.println(w);
Serial.println(x);
Serial.println(y);
Serial.println(z);
}

this program has recieve byte b = 0xff
but i want to use Serial.readString to type data from serial monitor
and use substring (1,4) to convert String(1,4) to byte
sorry my english not streght**

toInt()

i want to use Serial.readString to type data from serial monitor and use substring (1,4) to convert String(1,4) to byte

An alternative is to use 'Serial.parseInt()' to extract the value directly from the serial stream and avoid using the "String" class altogether.

if (Serial.available() > 0)
{
    byte val = Serial.parseInt();
    Serial.println(val, BIN);
    Serial.println(val, OCT);
    Serial.println(val, DEC);
    Serial.println(val, HEX);
}