다음을 통해 공유


AudienceManager.GetAudience Method (String)

Gets an instance of the Audience object that represents the audience with the specified name.

Namespace:  Microsoft.Office.Server.Audience
Assembly:  Microsoft.Office.Server.UserProfiles (in Microsoft.Office.Server.UserProfiles.dll)

Syntax

'Declaration
Public Function GetAudience ( _
    AudienceNameOrg As String _
) As Audience
'Usage
Dim instance As AudienceManager
Dim AudienceNameOrg As String
Dim returnValue As Audience

returnValue = instance.GetAudience(AudienceNameOrg)
public Audience GetAudience(
    string AudienceNameOrg
)

Parameters

Return Value

Type: Microsoft.Office.Server.Audience.Audience
Audience object that represents the audience with the specified name. Otherwise, a null reference (Nothing in Visual Basic) if the audience was not found or cannot be displayed within the current site.

Remarks

The GetAudience method provides a way to access an Audience object, assuming this audience is displayed within the current site.

Examples

The following code example shows how to get an Audience object by name and display basic information about that audience.

AudienceManager AudMgr = new AudienceManager();
Audience Aud = AudMgr.GetAudience("Audience Name");

if (Aud != null)
{
    System.Console.WriteLine("Audience.Name {0}", Aud.AudienceName);
    System.Console.WriteLine("Audience.AudienceDescription {0}", Aud.AudienceDescription);
    System.Console.WriteLine("Audience.AudienceID {0}", Audi.AudienceID.ToString());
    System.Console.WriteLine("Audience.AudienceSite {0}", Aud.AudienceSite);

}
Dim AudMgr As New AudienceManager()
Dim Aud As Audience = AudMgr.GetAudience("Audience Name")

If Aud IsNot Nothing Then
    System.Console.WriteLine("Audience.Name {0}", Aud.AudienceName)
    System.Console.WriteLine("Audience.AudienceDescription {0}", Aud.AudienceDescription)
    System.Console.WriteLine("Audience.AudienceID {0}", Audi.AudienceID.ToString())
    System.Console.WriteLine("Audience.AudienceSite {0}", Aud.AudienceSite)

End If

See Also

Reference

AudienceManager Class

AudienceManager Members

GetAudience Overload

Microsoft.Office.Server.Audience Namespace