Convering strings containing number

Salih Dincer salihdb at hotmail.com
Thu Jun 16 08:07:12 UTC 2022


On Wednesday, 15 June 2022 at 04:39:21 UTC, Mike Parker wrote:
>
> ```d
> str[3..4].to!int;
> ```

Thanks, I got the solution based on your answer.  I also created 
different slicing functions.  They work just fine without the 
need for conversion:

```d
     T solKes(string str, size_t a, size_t l)
     {
       import std.conv;
       const b = a + l;
       return str[a + 1..b].to!T;
     }

     T kalKes(string str, size_t a, size_t l)
     {
       import std.conv;
       const b = a + l;
       return str[b - 1..b].to!T;
     }

     T sagKes(string str, size_t a, size_t l)
     {
       import std.conv;
       const b = a + l;
       return str[a..b - 1].to!T;
     }

     T tekKes(string str, size_t a, size_t l)
     {
       import std.conv;
       return str[a..a + l].to!T;
     }
```
Thanks again...

SDB at 79



More information about the Digitalmars-d-learn mailing list