c#代码转VB.NET

yuelailiu 2011-02-23 09:08:00
请将以下代码转VB.NET,谢谢。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Enyim.Caching;

namespace BBS.Core
{
public class CrossSiteLoginInfoHelper
{
public static string Set(string userID)
{
string token = Guid.NewGuid().ToString("N");
return Set(token, userID) ? token : "";
}

public static bool Set(string token, string userID)
{
using (MemcachedClient client = new MemcachedClient())
{
return client.Store(Enyim.Caching.Memcached.StoreMode.Set, token, userID);
}
}

public static string Get(string token)
{
using (MemcachedClient client = new MemcachedClient())
{
return client.Get<string>(token);
}
}

public static string GetAndRemove(string token)
{
using (MemcachedClient client = new MemcachedClient())
{
string str = client.Get<string>(token);
client.Remove(token);
return str;
}
}
}
}
...全文
118 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
w3k 2011-02-24
  • 打赏
  • 举报
回复
很久没在CSDN冒水了,哈哈!
代码已转-
Address:China Hai nan
===========================================
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports Enyim.Caching

Namespace BBS.Core
Public Class CrossSiteLoginInfoHelper
Public Shared Function [Set](ByVal userID As String) As String
Dim token As String = Guid.NewGuid().ToString("N")
Return If([Set](token, userID), token, "")
End Function

Public Shared Function [Set](ByVal token As String, ByVal userID As String) As Boolean
Using client As New MemcachedClient()
Return client.Store(Enyim.Caching.Memcached.StoreMode.Set, token, userID)
End Using
End Function

Public Shared Function [Get](ByVal token As String) As String
Using client As New MemcachedClient()
Return client.Get(Of String)(token)
End Using
End Function

Public Shared Function GetAndRemove(ByVal token As String) As String
Using client As New MemcachedClient()
Dim str As String = client.Get(Of String)(token)
client.Remove(token)
Return str
End Using
End Function
End Class
End Namespace
luofenghen 2011-02-23
  • 打赏
  • 举报
回复
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports Enyim.Caching

Namespace BBS.Core
Public Class CrossSiteLoginInfoHelper
Public Shared Function Set(ByVal userID As String) As String
Dim token As String = Guid.NewGuid().ToString("N")
Return Set(token, userID) ? token : ""
End Function

Public Shared Function Set(ByVal token As String, ByVal userID As String) As Boolean
Imports (MemcachedClient client = New MemcachedClient())
{
Return client.Store(Enyim.Caching.Memcached.StoreMode.Set,token,userID)
}
End Function

Public Shared Function Get(ByVal token As String) As String
Imports (MemcachedClient client = New MemcachedClient())
{
Return client.Get<string>(token)
}
End Function

Public Shared Function GetAndRemove(ByVal token As String) As String
Imports (MemcachedClient client = New MemcachedClient())
{
Dim str As String = client.Get<string>(token)
client.Remove(token)
Return str
}
End Function
End Class
End Namespace

代码已转 请调试 不客气
yuelailiu 2011-02-23
  • 打赏
  • 举报
回复
调用部分:
Protected ObjCrossSiteLoginInfoHelper As CrossSiteLoginInfoHelper = New CrossSiteLoginInfoHelper
Dim strUserId As String = "11111"
strToken = ObjCrossSiteLoginInfoHelper.Set(strUserId)

调转到异常:
using (MemcachedClient client = new MemcachedClient())
{
return client.Store(Enyim.Caching.Memcached.StoreMode.Set, token, userID);
}


异常信息:(少了什么配置参数?)
Invalid or missing pool configuration. Check if the enyim.com/memcached section or your custom section presents in the app/web.config. 参数名: configuration
wuyq11 2011-02-23
  • 打赏
  • 举报
回复
http://www.developerfusion.com/tools/convert/csharp-to-vb/
xingyuebuyu 2011-02-23
  • 打赏
  • 举报
回复
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports Enyim.Caching

Namespace BBS.Core
Public Class CrossSiteLoginInfoHelper
Public Shared Function [Set](userID As String) As String
Dim token As String = Guid.NewGuid().ToString("N")
Return IIf([Set](token, userID), token, "")
End Function

Public Shared Function [Set](token As String, userID As String) As Boolean
Using client As New MemcachedClient()
Return client.Store(Enyim.Caching.Memcached.StoreMode.[Set], token, userID)
End Using
End Function

Public Shared Function [Get](token As String) As String
Using client As New MemcachedClient()
Return client.[Get](Of String)(token)
End Using
End Function

Public Shared Function GetAndRemove(token As String) As String
Using client As New MemcachedClient()
Dim str As String = client.[Get](Of String)(token)
client.Remove(token)
Return str
End Using
End Function
End Class
End Namespace
modaidizi 2011-02-23
  • 打赏
  • 举报
回复
http://www.developerfusion.com/tools/convert/csharp-to-vb/

16,552

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧