web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
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

  • Suggested answer
    Jonathan  Halland Profile Picture
    11,310 on at

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

    info(char);

    //prints "H";

  • Suggested answer
    Tommy Skaue Profile Picture
    Microsoft Employee on at

    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
    Ivan (Vanya) Kashperuk Profile Picture
    Microsoft Employee on at

       str text = "3343343";

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

  • Community Member Profile Picture
    on at

    Please refer below link sample example for your related query

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

  • Community Member Profile Picture
    on at

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

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Prashant Singh Profile Picture

Prashant Singh 2

#1
nmaenpaa Profile Picture

nmaenpaa 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans