如何用新字母递增字符串并使其始终保持唯一 [英] How to increment a string with a new alphabet and make it unique all the time

查看:84
本文介绍了如何用新字母递增字符串并使其始终保持唯一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行webtest,需要使用名称作为参数.但是每个Webtest的名称都应该是唯一的,而不是像Mathew或john这样的普通名称.它应该类似于ahrjakajrdkj,然后下一次应不同于ahrjakajrdkj.它可以是ahrjakajrdkji或类似的东西(但与第一个不同).我正在使用C Sharp作为代码库.请帮忙

谢谢,
D

I am doing webtest where I need to use a name as a parameter. But the name should be unique for each webtest.It should not be a normal name like mathew or john. It should be something like ahrjakajrdkj and then next time it should be different from ahrjakajrdkj. It can be ahrjakajrdkji or something like that (but different from the first one). I am using C sharp as the code base. Please help

Thanks,
D

推荐答案

使用Random类生成长度.该长度可以由任意长度限制,例如2和32.然后使用StringBuilder和相同的Random对象创建随机字符串.
Use the Random class to generate a length. The length could be something bound by some arbitrary lengths like 2 and 32. Then use a StringBuilder and the same Random object to create a random string of characters.


可以"您是否以某种方式创建了GUID,然后将其转换为字符串?它不会像"ahrjakajrdkj",但可能是唯一的.

用于创建GUID:
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=335
Can''t you somehow create a GUID and then convert it to string? It will not be like "ahrjakajrdkj" but will probably be unique.

For creating GUIDs:
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=335


使用向导-保证每次都是唯一的.

编辑==========

糟糕-有人已经建议过...
Use a Guid - guaranteed to be unique every time.

EDIT ==========

Ooops - someone already suggested it...


这篇关于如何用新字母递增字符串并使其始终保持唯一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆