开发者

C# how to flip a string vertically

开发者 https://www.devze.com 2023-03-12 00:07 出处:网络
Is it possible to flip a string vertically in C#, e.g. given string s= \"123456\"; The result is: I need to assign the resulting string to a string type in C#.

Is it possible to flip a string vertically in C#, e.g. given

string s= "123456";

The result is:

C# how to flip a string vertically

I need to assign the resulting string to a string type in C#.

The reason I need the function is that I have a chart that needs to be rotated to meet requirements. Therefore, any te开发者_JS百科xts within the chart have to be rotated.


You mean you want to render it upside down.

Strings do not have an "orientation" in and of themselves - this is entirely something to do with rendering them for display.

You can use the classes in the System.Drawing to create an image with each character displayed upside down (an image transform with RotateFlipType for example), though whether this is a good option entirely depends on what technology you are using and how you want to display and use the text.


If you're using WPF or Silverlight, this is fairly easy. Just apply a ScaleTransform with a scale of (1.0, -1.0) to the rendered text.


You can use transform in WPF and rotate it in any angle

<RotateTransform CenterX="0" CenterY="0" Angle="180" />

UPD: sorry, i've probably misunderstood your question. You can use a VisualBrush to do this.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号