Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

How to get one char from string?

(0) ShareShare
ReportReport
Posted on by 585

I try convert some code C# to X++.

Cyfra = Convert.ToInt32(Convert.ToString(Tekst[i]));

How write this same code in X++? 

I have:

System.String netTekst;
Cyfra = str2int   (netTekst[i]);


But, I have error. ... " You try use GetValue"

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to get one char from string?

    str2int will return 0 for alphanumerics, isInteger() or str2intOk() should be used.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to get one char from string?

    Please refer below link sample example for your related query

    axaptacorner.blogspot.in/.../important-function-in-x-for-ax-2009-and.html

  • Suggested answer
    RE: How to get one char from string?

       str text = "3343343";

       int i = str2int(subStr(text, 3, 1));

  • Suggested answer
    skaue Profile Picture
    skaue on at
    RE: How to get one char from string?

    Often the problem when mixing managed code with unmanaged is casting between the types. In many cases you will not be able to implicitly cast between X++ types and .Net types and you need to save the value in a local variable first and cast second. :-)

    Grab whatever is in netTekst[i] into a local variable and try send it into str2int.

  • Suggested answer
    Jonathan  Halland Profile Picture
    Jonathan Halland 11,304 on at
    RE: How to get one char from string?

    str char =  subStr("Hello",1,1);

    info(char);

    //prints "H";

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,431 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans