在调试上下文列表中表示内容的更好方法是什么?

时间:2017-10-16 03:01:52

标签: c# .net debugging visual-studio-2017 debuggervisualizer

至少在调试模式下,是否有一种不那么繁琐的方法来检查填充列表的内容?我想说它是一个可视化器......?我的谷歌今晚虽然失败了。感谢。

enter image description here

我最终在这里下载了ML Collection Visualizer 2015-2017:https://www.codeproject.com/Articles/1181451/Visual-Studio-Collection-Visualizers

3 个答案:

答案 0 :(得分:3)

为您的班级使用DebuggerDisplayAttribute

    <div class="form-group">
        <label for="type" class="control-label">Type</label>
        <select class="form-control selectpicker" title="Type of Asset" name="type" data-live-search="true" id="type" onchange="typePicker()">
            <option value="aps">Access Point</option>
            <option value="cables">Cable</option>
            <option value="desktops">Desktop</option>
            <option value="laptops">Laptop</option>
            <option value="deskPhones">Desk Phone</option>
            <option value="mobilePhones">Mobile Phone</option>
            <option value="monitors">Monitor</option>
            <option value="printers">Printer</option>
            <option value="projectors">Projector</option>
            <option value="routers">Router</option>
            <option value="switches">Switch</option>
            <option value="tablets">Tablet</option>
            <option value="other">Other</option>
        </select>
    </div>
    
    <div class="form-group" id="typeInputs">
        <div id="aps">
            <div class="form-group">
                <input type="text" class="form-control" name="ipaddress" id="ipaddress" placeholder="IP Address">
            </div> <!-- IP Address -->
            
            <div class="form-group">
                <input type="text" class="form-control" name="mac-address" id="mac-address" placeholder="MAC Address">
            </div> <!-- MAC Address -->
            
            <div class="form-group">
                <input type="text" class="form-control" name="range" id="range" placeholder="Range in M">
            </div> <!-- Range -->
            
            <div class="form-group">
                <input type="text" class="textbox-n form-control" name="bands" id="bands" placeholder="Bands" >
            </div> <!-- Bands -->
            
            <div class="form-group">
                <input type="text" class="form-control" name="channels" id="channels" placeholder="Channel(s)">
            </div> <!-- Channels -->
            
            <div class="form-group">
                <input placeholder="Date Bought" class="textbox-n form-control" type="text" onfocus="(this.type=\'date\')" onblur="(this.type\'text\')" id="date-bought" name="dateBought">
            </div> <!-- Date Bought -->
            
            <div class="btn-group" data-toggle="buttons">
                <label for="poe">PoE</label>
                <br>
                <label class="btn btn-primary"><input type="radio" name="poe" id="option1"> Yes</label>
                <label class="btn btn-primary"><input type="radio" name="poe" id="option2"> No</label>
            </div>  <br><br><!-- PoE -->
            
            <div class="form-group">
                <input placeholder="Warranty Expiration Date" class="textbox-n form-control" type="text" onfocus="(this.type=\'date\')" onblur="(this.type=\'text\')" id="warranty-date" name="warrantyDate">
            </div><!-- Warranty Date -->
            
            <div class="form-group">
                <input class="form-control"  id="location" placeholder="Location">
            </div><!-- Location -->
        </div>
    </div>
    
    <div class="form-gorup" id="warningType">
      
    </div>

答案 1 :(得分:1)

作为Backs回答的替代方法,您可以覆盖类的ToString()方法以达到相同的效果。

public sealed class MyClass   
{      
    public int count { get; set; }      
    public bool flag { get; set; }      
    public override string ToString() 
    {
        return string.Format("{0},{1}", count, flag);
    }
}

答案 2 :(得分:0)

我最终在这里下载了ML Collection Visualizer 2015-2017:https://www.codeproject.com/Articles/1181451/Visual-Studio-Collection-Visualizers

虽然有多个合法答案,但上面是我正在寻找的。谢谢大家。

enter image description here