Mid and InStrRev conversion to c#

  • Thread starter Thread starter sck10
  • Start date Start date
S

sck10

Hello,

I am converting a DataList from vb to c#. I am having a problem converting
the Mid function with InStrRev to c#. Any help with this would be
appreciated.

<asp:DataList id="dlstPhotoGallery" Runat="Server"
RepeatDirection="Horizontal">
<ItemTemplate>
<a href='<%# Replace(Container.DataItem,"_mini","") %>' target="_blank">
<asp:Image ID="imgPhotoGallery" ImageUrl='<%# Container.DataItem %>'
ToolTip='<%# Mid(Container.DataItem, InStrRev(Container.DataItem, "/")
+ 1) %>' Runat="Server" />
</a>
</ItemTemplate>
</asp:DataList>
</asp:Panel>
 
For Mid, you can use a substring. Put the position (0 based) and the length
you desire. I forget what InStrRev contains.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
 
Mid - String.Substring()
InStrRev - String.LastIndexOf()

Hello,

I am converting a DataList from vb to c#. I am having a problem converting
the Mid function with InStrRev to c#. Any help with this would be
appreciated.

<asp:DataList id="dlstPhotoGallery" Runat="Server"
RepeatDirection="Horizontal">
<ItemTemplate>
<a href='<%# Replace(Container.DataItem,"_mini","") %>' target="_blank">
<asp:Image ID="imgPhotoGallery" ImageUrl='<%# Container.DataItem %>'
ToolTip='<%# Mid(Container.DataItem, InStrRev(Container.DataItem, "/")
+ 1) %>' Runat="Server" />
</a>
</ItemTemplate>
</asp:DataList>
</asp:Panel>
 
The following was produced with our Instant C# VB to C# converter (asp.net
snippet tab):

<asp:DataList id="dlstPhotoGallery" Runat="Server"
RepeatDirection="Horizontal">
<ItemTemplate>
<a href='<%#Container.DataItem.Replace("_mini", "")%>'
target="_blank">
<asp:Image ID="imgPhotoGallery" ImageUrl='<%#Container.DataItem%>'

ToolTip='<%#Container.DataItem.Substring((Container.DataItem.LastIndexOf("/")
+ 1))%>'
Runat="Server" />
</a>
</ItemTemplate>
</asp:DataList>
</asp:Panel>

By the way, while Reflector is a great tool, it's impractical for most
conversion purposes. The main goal in conversion is not just to get code
that runs in another language, but to get code that conveys the same
information and is understood. Any tool that converts to IL and back again
will be obscured with convoluted IL interpretations & optimizations and
missing comments. In addition, it would be very impractical to convert
ASP.NET in-line code.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
C# Code Metrics: Quick metrics for C#
 
Thanks David, appreciate the help...


David Anton said:
The following was produced with our Instant C# VB to C# converter (asp.net
snippet tab):

<asp:DataList id="dlstPhotoGallery" Runat="Server"
RepeatDirection="Horizontal">
<ItemTemplate>
<a href='<%#Container.DataItem.Replace("_mini", "")%>'
target="_blank">
<asp:Image ID="imgPhotoGallery" ImageUrl='<%#Container.DataItem%>'

ToolTip='<%#Container.DataItem.Substring((Container.DataItem.LastIndexOf("/")
+ 1))%>'
Runat="Server" />
</a>
</ItemTemplate>
</asp:DataList>
</asp:Panel>

By the way, while Reflector is a great tool, it's impractical for most
conversion purposes. The main goal in conversion is not just to get code
that runs in another language, but to get code that conveys the same
information and is understood. Any tool that converts to IL and back
again
will be obscured with convoluted IL interpretations & optimizations and
missing comments. In addition, it would be very impractical to convert
ASP.NET in-line code.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
C# Code Metrics: Quick metrics for C#
 
Back
Top